Skip to content

Instantly share code, notes, and snippets.

@mvllow
Last active January 23, 2021 21:01
Show Gist options
  • Save mvllow/c1eeeafb6868dc523b1bcb78644ec769 to your computer and use it in GitHub Desktop.
Save mvllow/c1eeeafb6868dc523b1bcb78644ec769 to your computer and use it in GitHub Desktop.
airbnb eslint + react + prettier + (optional) typescript
/*
# 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