UNPKG

@rajzik/config-eslint

Version:
153 lines (152 loc) 7.16 kB
"use strict"; const lumos_common_1 = require("@rajzik/lumos-common"); // In TS, all arguments are required for type information, // so we need to override the base JS setting. const noUnused = { vars: 'all', args: 'none', ignoreRestSiblings: true }; // Project references and some projects currently cause OOM errors, // so let's use a specialized TS config that globs everything. const project = lumos_common_1.fromRoot('tsconfig.eslint.json', true) || lumos_common_1.fromRoot('tsconfig.json'); const config = { settings: { 'import/resolver': { typescript: {}, }, 'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'], }, }, parserOptions: { project, }, overrides: [ { files: ['*.{ts,tsx}'], parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], rules: { 'func-call-spacing': 'off', 'no-restricted-globals': 'off', 'no-unused-vars': 'off', 'no-unused-expressions': 'off', camelcase: 'off', 'no-shadow': 'off', 'no-use-before-define': 'off', 'no-undef': 'off', // IMPORT (Conflicts with TS patterns) 'import/extensions': [ 'error', 'never', { json: 'always', }, ], 'import/named': 'off', 'import/no-cycle': 'off', 'import/no-named-as-default': 'off', 'import/prefer-default-export': 'warn', 'import/no-extraneous-dependencies': [ 'error', { devDependencies: [ `test/**/*.${lumos_common_1.EXTS_GROUP}`, `tests/**/*.${lumos_common_1.EXTS_GROUP}`, `**/*.test.${lumos_common_1.EXTS_GROUP}`, `**/jest.config.${lumos_common_1.EXTS_GROUP}`, `**/webpack.config.${lumos_common_1.EXTS_GROUP}`, `**/webpack.config.*.${lumos_common_1.EXTS_GROUP}`, ], optionalDependencies: false, }, ], // REACT (We don't use prop types) 'react/default-props-match-prop-types': 'off', 'react/jsx-filename-extension': [ 'error', { extensions: ['.tsx'], }, ], 'react/no-unused-prop-types': 'off', 'react/prop-types': 'off', 'react/require-default-props': 'off', // UNICORN 'unicorn/no-fn-reference-in-iterator': 'off', // TYPESCRIPT '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/await-thenable': 'error', // '@typescript-eslint/class-name-casing': ['error', { allowUnderscorePrefix: true }], '@typescript-eslint/consistent-type-assertions': [ 'error', { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }, ], '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/func-call-spacing': ['error', 'never'], '@typescript-eslint/member-delimiter-style': 'error', '@typescript-eslint/member-ordering': 'off', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/array-type': [ 'warn', { default: 'array-simple', }, ], '@typescript-eslint/consistent-type-imports': [ 'warn', { prefer: 'no-type-imports', }, ], '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-empty-interface': 'error', '@typescript-eslint/ban-types': [ 'error', { types: { Function: "Don't use Function as a type. Use explicit types like `(...args: any[]) => void`", String: { message: 'Use string instead', fixWith: 'string', }, }, }, ], '@typescript-eslint/no-inferrable-types': 'warn', '@typescript-eslint/method-signature-style': ['warn', 'method'], '@typescript-eslint/no-explicit-any': [ 'error', { fixToUnknown: false, ignoreRestArgs: true }, ], '@typescript-eslint/prefer-includes': 'warn', '@typescript-eslint/prefer-regexp-exec': 'warn', '@typescript-eslint/prefer-ts-expect-error': 'warn', '@typescript-eslint/no-unnecessary-type-assertion': 'error', '@typescript-eslint/no-extra-parens': 'error', '@typescript-eslint/no-for-in-array': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-parameter-properties': 'error', '@typescript-eslint/no-require-imports': 'error', '@typescript-eslint/no-throw-literal': 'error', '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', '@typescript-eslint/no-unsafe-call': 'warn', '@typescript-eslint/no-unsafe-member-access': 'warn', '@typescript-eslint/no-unsafe-return': 'warn', '@typescript-eslint/no-unused-vars': ['error', noUnused], '@typescript-eslint/no-use-before-define': 'error', '@typescript-eslint/no-shadow': 'error', '@typescript-eslint/prefer-as-const': 'error', '@typescript-eslint/prefer-for-of': 'error', '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/prefer-nullish-coalescing': 'off', '@typescript-eslint/prefer-optional-chain': 'error', '@typescript-eslint/promise-function-async': 'off', '@typescript-eslint/require-await': 'error', '@typescript-eslint/switch-exhaustiveness-check': 'error', '@typescript-eslint/triple-slash-reference': 'error', '@typescript-eslint/type-annotation-spacing': 'error', '@typescript-eslint/unified-signatures': 'error', }, }, ], }; module.exports = config;