[@typescript-eslint/no-unused-vars] Use config of ESLint built-in "no-unused-vars" rule when no config exists for typescript counterpart · Issue #268 · typescript-eslint/typescript-eslint · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
<
8000
div class="flex-auto min-width-0 width-fit">
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 explicitlty require-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'],
// ...
},
};
The text was updated successfully, but these errors were encountered:
Please don't create duplicate issues with the exact same body if all you're doing is changing the title.
This just creates a lot of noise for us maintainers.
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'
: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 explicitlty
require
-ing the rules of the "eslint-config-airbnb-base" module and then re-configure them using the imported rule config:The text was updated successfully, but these errors were encountered: