Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
In our.eslintrc.js
we use the configuration of'airbnb-base'
that enables and configures the ESLint built-in rules of "camelcase", "indent", "no-array-constructor" and "no-unused-vars".
To ensure that we don't get double rule violations (on for the ESLint build-in and the TypeScript counterpart),
we deliberately place'plugin:@typescript-eslint/recommended'
after'airbnb-base'
:
module.exports = { extends: [ 'eslint:recommended', 'airbnb-base', // placed after 'airbnb-base' so that enabled rules are replaced with TypeScript specific ones 'plugin:@typescript-eslint/recommended', ], // ...};
Problem with this approach is that@typescript-eslint/eslint-plugin
will use a different configuration as the for the ESLint built-in rules of "camelcase", "indent", "no-array-constructor" and "no-unused-vars".
So I was wondering if it wouldn't be possible that@typescript-eslint/eslint-plugin
uses the configuration of ESLint built-in rules in case no explicit configuration exists for the TypeScript counterparts.
Right now, we had to work around the problem by explicitltyrequire
-ing the rules of the "eslint-config-airbnb-base" module and then re-configure them using the imported rule config:
const airbnbImportsRules = require('eslint-config-airbnb-base/rules/imports').rules;const airbnbStyleRules = require('eslint-config-airbnb-base/rules/style').rules;const airbnbVariablesRules = require('eslint-config-airbnb-base/rules/variables').rules;module.exports = { extends: [ 'eslint:recommended', 'airbnb-base', // placed after 'airbnb-base' so that enabled rules are replaced with TypeScript specific ones 'plugin:@typescript-eslint/recommended', ], plugins: ['@typescript-eslint'], settings: { 'import/resolver': { 'webpack': { config: path.join(__dirname, 'webpack.config.prod.js'), } }, }, env: { browser: true, es6: true, }, parser: '@typescript-eslint/parser', parserOptions: { 'project': './tsconfig.json' }, rules: { // ... // configure TypeScript counterpart rules with the original airbnb rule configuration '@typescript-eslint/camelcase': airbnbStyleRules.camelcase, '@typescript-eslint/indent': airbnbStyleRules.indent, '@typescript-eslint/no-array-constructor': airbnbStyleRules['no-array-constructor'], '@typescript-eslint/no-unused-vars': airbnbVariablesRules['no-unused-vars'], // ... },};