npm install @lexjs/eslint-plugin --save-dev
pnpm add @lexjs/eslint-plugin --save-dev
yarn add @lexjs/eslint-plugin --dev
// eslint.config.js
import lexjs from '@lexjs/eslint-plugin';
export default [
// other configs
...lexjs.configs.recommended,
...lexjs.configs.typescript,
// other configs
];
Extends Configs
- ESLint
- Recommended
- Prettier
- Recommended
- Import Plugin
- Recommended
Rules
{
eqeqeq: ['error', 'smart'],
'prefer-const': 'warn',
'object-shorthand': 'error',
'consistent-return': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'lines-between-class-members': ['error', 'always'],
'no-console': 'warn',
}
Import Rules
{
'import/no-cycle': 'error',
'import/no-duplicates': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-named-as-default-member': 'off',
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'export' },
{ blankLine: 'always', prev: 'export', next: '*' },
{ blankLine: 'any', prev: 'export', next: 'export' },
],
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'unused-imports/no-unused-imports': 'error',
}
Extends Configs
- TypeScript ESLint
- Recommended
- ESLint Recommended
- Import Plugin
- TypeScript
Files
'**/*.{ts,tsx}'
Rules
{
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
ignoreRestSiblings: true,
},
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allowSingleOrDouble',
trailingUnderscore: 'forbid',
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
}
Import Settings
{
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
}
Configure ESLint to ignore certain files and directories by including patterns from a .gitignore
or any other file with gitignore-style patterns.
Type
function useIgnoreFile(file: string, meta: ImportMeta): FlatConfig;
Usage
// eslint.config.js
import { useIgnoreFile } from '@lexjs/eslint-plugin/utils';
export default [
useIgnoreFile('.gitignore', import.meta),
// other configs
];
File name must be resolved relative to the ESLint config file.