Typescript + Airbnb generated config isn't working at all?
baptisteArno opened this issue · comments
I used the cli to generate my eslint config file and I chose Typescript support and Airbnb rules and it generated this config file:
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'airbnb-base',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {},
};
But it seems that it is not adapted to a Typescript project because there are some issues with the imports saying that it needs an extension (Airbnb rule not compliant with Typescript) so we need to modify the config like so:
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'airbnb-base',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
},
};
And now I have a problem with all my enum
s as well, saying that they are declared in the upper scope
Are these behaviors expected?
EDIT:
I managed to have a Typescript working config:
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
'airbnb-base',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
};
Should I make a PR?
Thanks for the issue.
I think its better that user configure that manually, because many have different preferences.
You can always create your custom config and release that to be used by others.
Looks like there is already a similar config being used quite widely.
Thank you @anikethsaha! Isn't it weird to have a generated config that doesn't work?
What command you used ? is it eslint init
?
also, its not possible to cover all cases with single config. this will generate basic config with can be customized by the users.
To reproduce: Use eslint init
and select "Node, Typescript, Airbnb". Right away, there are some issues with the imports saying that it needs an extension (conflict between Typescript and Airbnb rules)