UNPKG

@airbnb/config-eslint

Version:
113 lines (112 loc) 5.46 kB
"use strict"; const nimbus_common_1 = require("@airbnb/nimbus-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 = nimbus_common_1.fromRoot('tsconfig.eslint.json', true) || nimbus_common_1.fromRoot('tsconfig.json'); const config = { settings: { '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', // 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/no-extraneous-dependencies': [ 'error', { devDependencies: [ `test/**/*.${nimbus_common_1.EXTS_GROUP}`, `tests/**/*.${nimbus_common_1.EXTS_GROUP}`, `**/*.test.${nimbus_common_1.EXTS_GROUP}`, `**/jest.config.${nimbus_common_1.EXTS_GROUP}`, `**/webpack.config.${nimbus_common_1.EXTS_GROUP}`, `**/webpack.config.*.${nimbus_common_1.EXTS_GROUP}`, ], optionalDependencies: false, }, ], // REACT (We dont 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/no-empty-function': 'off', '@typescript-eslint/no-empty-interface': 'error', '@typescript-eslint/no-explicit-any': [ 'error', { fixToUnknown: true, ignoreRestArgs: true }, ], '@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/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;