Last active
May 10, 2021 20:32
-
-
Save NonPolynomial/74e3766b035779265480e29176fa6443 to your computer and use it in GitHub Desktop.
disable airbnb rules when using typescript-eslint
This file contains hidden or 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
| const tsRules = Reflect.ownKeys( | |
| require('@typescript-eslint/eslint-plugin').rules, | |
| ); | |
| const airbnbRules = require('eslint-config-airbnb-base') | |
| .extends.map((e) => Reflect.ownKeys(require(e).rules)) | |
| .reduce((acc, cur) => [...acc, ...cur], []); | |
| const disabledRules = airbnbRules | |
| .filter((airbnbRule) => tsRules.includes(airbnbRule)) | |
| .map((airbnbRule) => ({ [airbnbRule]: 'off' })) | |
| .reduce((acc, cur) => ({ ...acc, ...cur }), {}); | |
| module.exports = { | |
| root: true, | |
| parser: '@typescript-eslint/parser', | |
| parserOptions: { | |
| project: './tsconfig.json', | |
| }, | |
| plugins: ['@typescript-eslint'], | |
| extends: [ | |
| 'eslint:recommended', | |
| 'plugin:@typescript-eslint/recommended', | |
| 'airbnb-base', | |
| // 'prettier', | |
| ], | |
| settings: { | |
| 'import/resolver': { | |
| node: { | |
| extensions: ['.js', '.jsx', '.ts', '.tsx'], | |
| }, | |
| }, | |
| }, | |
| rules: { | |
| ...disabledRules, | |
| 'import/extensions': [ | |
| 2, | |
| 'ignorePackages', | |
| { | |
| js: 'never', | |
| mjs: 'never', | |
| jsx: 'never', | |
| ts: 'never', | |
| tsx: 'never', | |
| }, | |
| ], | |
| 'implicit-arrow-linebreak': 0, | |
| /* airbnb (with react / JSX) */ | |
| 'react/jsx-filename-extension': [ | |
| 1, | |
| { allow: 'as-needed', extensions: ['.tsx'] }, | |
| ], | |
| 'react/jsx-props-no-spreading': 1, | |
| // meh for typescript -> use `FC<PropTypes>` | |
| 'react/prop-types': 'off', | |
| // not in Next.js context | |
| 'react/react-in-jsx-scope': 0, | |
| }, | |
| }; |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| pnpm add -D eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier eslint-config-airbnb-base | |
| pnpm info eslint-config-airbnb-base | |
| // install peerDependencies... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment