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 Jan 18, 2021
1 parent 63db4e6 commit 166b151
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
@@ -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
Expand Up @@ -83,7 +83,7 @@
"codegen:typechain": "cp ./node_modules/@mstable/protocol/build/contracts/*.json ./lib/abis/combined && cp ./lib/abis/overrides/*.json ./lib/abis/combined && yarn typechain --target ethers-v4 --outDir src/typechain './lib/abis/combined/*.json'",
"eject": "react-scripts eject",
"lint": "yarn eslint './src/**/*.{ts,tsx}' --fix",
"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 166b151

Please sign in to comment.