Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Workaround for CRA issue
Browse files Browse the repository at this point in the history
- Add workaround for facebook/create-react-app#9929
  • Loading branch information
JamesLefrere committed Dec 23, 2020
1 parent 53ccb62 commit 108a2cc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 39 deletions.
38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

53 changes: 53 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const realConfig = {
extends: [
'airbnb-typescript',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
env: {
node: true,
browser: true,
jest: true,
},
parserOptions: {
project: './tsconfig.json',
},
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{ allowExpressions: true, allowTypedFunctionExpressions: true },
],
'@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '_' }],
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/naming-convention': 'off',
'arrow-body-style': 'off',
'no-underscore-dangle': 'off',
'no-console': ['error', { allow: ['warn', 'error'] }],
'react/no-unescaped-entities': 'off',
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
'react/prop-types': 'off',
'no-nested-ternary': 'off',
},
};

const nopConfig = {
/*
This config is meant to do nothing.
It exists because there's no good way to disable ESLint in Create React App:
https://github.com/facebook/create-react-app/issues/9929
So the workaround here is to craft a config that does as little as possible,
and then conditionally use it.
*/

ignorePatterns: ['**/*.ts', '**/*.tsx', './*.js', 'config/*.js'],
};

module.exports = process.env.DISABLE_ESLINT ? nopConfig : realConfig;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"eject": "react-scripts eject",
"lint": "yarn eslint './src/**/*.{ts,tsx}' --fix",
"provision": "sh ./scripts/provision.sh",
"start": "react-scripts start",
"start": "DISABLE_ESLINT=true react-scripts start",
"test:ropsten": "env-cmd -f .env.example.ropsten react-scripts test",
"test": "react-scripts test",
"script": "yarn ts-node --project ./scripts/tsconfig.json ./scripts/run.ts",
Expand Down

0 comments on commit 108a2cc

Please sign in to comment.