Last active
January 23, 2021 21:01
-
-
Save mvllow/c1eeeafb6868dc523b1bcb78644ec769 to your computer and use it in GitHub Desktop.
airbnb eslint + react + prettier + (optional) typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# airbnb | |
# supports react + hooks | |
$ npx install-peerdeps --yarn --dev eslint-config-airbnb | |
# with prettier | |
$ yarn add --dev prettier eslint-config-prettier eslint-plugin-prettier | |
*/ | |
module.exports = { | |
env: { | |
node: true, | |
browser: true, | |
}, | |
extends: [ | |
'airbnb', | |
'airbnb/hooks', | |
'prettier/react', | |
'plugin:prettier/recommended', | |
], | |
rules: { | |
'prettier/prettier': 'error', | |
'react/jsx-filename-extension': 0, | |
}, | |
} | |
/* | |
# with typescript | |
$ yarn add --dev typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser | |
*/ | |
module.exports = { | |
// ... | |
parser: '@typescript-eslint/parser', | |
extends: [ | |
// ... | |
'plugin:@typescript-eslint/recommended', | |
], | |
settings: { | |
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'], | |
'import/parsers': { | |
'@typescript-eslint/parser': ['.ts', '.tsx'], | |
}, | |
'import/resolver': { | |
node: { | |
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'], | |
}, | |
}, | |
}, | |
rules: { | |
// ... | |
// allow triple slash comments (eg. declaration files) | |
'spaced-comment': ['error', 'always', { markers: ['/'] }], | |
// fix import errors (https://github.com/benmosher/eslint-plugin-import/issues/1615) | |
'import/extensions': [ | |
'error', | |
'ignorePackages', | |
{ | |
js: 'never', | |
jsx: 'never', | |
ts: 'never', | |
tsx: 'never', | |
}, | |
], | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment