UNPKG

@hybrbase/eslint-config

Version:
191 lines (190 loc) 5.29 kB
module.exports = { env: { es6: true, node: true, }, parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, globalReturn: false, }, ecmaVersion: 2020, project: ['tsconfig.json'], sourceType: 'module', }, settings: { 'import/resolver': { typescript: {}, node: { extensions: ['.js', '.jsx', '.ts', '.tsx'], }, }, }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:import/recommended', 'plugin:import/typescript', ], rules: { 'import/extensions': 'off', // https://medium.com/@steven-lemon182/are-typescript-barrel-files-an-anti-pattern-72a713004250 'import/no-cycle': 2, // will use 'import/no-duplicates'. 'no-duplicate-imports': 'off', 'no-unused-vars': 'off', 'spaced-comment': [ 'error', 'always', { line: { markers: ['/'], exceptions: ['-', '+'], }, block: { markers: ['!'], exceptions: ['*'], balanced: true, }, }, ], 'linebreak-style': ['error', 'unix'], 'no-empty-function': 'off', 'import/default': ['error'], // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md 'import/no-duplicates': ['error', { 'prefer-inline': true, considerQueryString: true }], 'import/no-named-as-default-member': ['warn'], 'import/no-named-as-default': ['warn'], 'import/order': [ 'error', { groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'], alphabetize: { order: 'asc', caseInsensitive: true }, }, ], '@typescript-eslint/no-unused-vars': [ 'error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true, }, ], '@typescript-eslint/ban-tslint-comment': ['error'], '@typescript-eslint/ban-ts-comment': [ 'error', { 'ts-expect-error': 'allow-with-description', minimumDescriptionLength: 10, 'ts-ignore': true, 'ts-nocheck': true, 'ts-check': false, }, ], '@typescript-eslint/no-explicit-any': ['error', { ignoreRestArgs: false }], '@typescript-eslint/no-empty-function': ['error', { allow: ['private-constructors'] }], // '@typescript-eslint/no-unused-vars': [ // 'warn', // { argsIgnorePattern: '^_', ignoreRestSiblings: true }, // ], '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/consistent-type-imports': [ 'warn', { prefer: 'type-imports', fixStyle: 'inline-type-imports' }, ], '@typescript-eslint/naming-convention': [ 'error', { selector: 'default', format: ['camelCase'], leadingUnderscore: 'forbid', trailingUnderscore: 'forbid', }, { selector: 'variable', format: ['camelCase'], leadingUnderscore: 'allow', }, { selector: ['function'], format: ['camelCase'], }, { selector: 'parameter', format: ['camelCase'], leadingUnderscore: 'allow', }, { selector: 'class', format: ['PascalCase'], }, { selector: 'classProperty', format: ['camelCase'], leadingUnderscore: 'allow', }, { selector: 'objectLiteralProperty', format: [ 'camelCase', // Some external libraries use snake_case for params 'snake_case', // Env variables are generally uppercase 'UPPER_CASE', // DB / Graphql might use PascalCase for relationships 'PascalCase', ], leadingUnderscore: 'allowSingleOrDouble', trailingUnderscore: 'allowSingleOrDouble', }, { selector: ['typeAlias', 'interface'], format: ['PascalCase'], }, { selector: ['typeProperty'], format: ['camelCase'], // For graphql __typename leadingUnderscore: 'allowDouble', }, { selector: ['typeParameter'], format: ['PascalCase'], }, ], }, overrides: [ { files: ['*.mjs'], parserOptions: { ecmaVersion: 'latest', sourceType: 'module', }, rules: { '@typescript-eslint/naming-convention': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/consistent-type-exports': 'off', '@typescript-eslint/consistent-type-imports': 'off', }, }, { // commonjs or assumed files: ['*.js', '*.cjs'], parser: 'espree', parserOptions: { ecmaVersion: 2020, }, rules: { '@typescript-eslint/naming-convention': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/consistent-type-exports': 'off', '@typescript-eslint/consistent-type-imports': 'off', 'import/order': 'off', }, }, ], }