-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate fork-ts-checker-webpack-plugin example to use ESLint (#960)
* move fork-ts-checker-webpack-plugin * make prettier correct * add lint rule timings * switch to released version of fork-ts-checker-webpack-plugin
- Loading branch information
1 parent
d0f6203
commit 416fa24
Showing
12 changed files
with
893 additions
and
313 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Useful references: | ||
// https://www.npmjs.com/package/eslint-config-react-app | ||
// https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/index.js | ||
// https://medium.com/@dors718/linting-your-react-typescript-project-with-eslint-and-prettier-2423170c3d42 | ||
|
||
const path = require('path'); | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', // Specifies the ESLint parser | ||
plugins: [ | ||
'@typescript-eslint', | ||
'react' | ||
// 'prettier' commented as we don't want to run performance hog prettier through eslint as it's slow | ||
], | ||
env: { | ||
browser: true, | ||
jest: true | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin | ||
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier | ||
// 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react | ||
'prettier/react', // disables react-specific linting rules that conflict with prettier | ||
// 'plugin:prettier/recommended' // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. | ||
], | ||
parserOptions: { | ||
project: path.resolve(__dirname, './tsconfig.json'), | ||
tsconfigRootDir: __dirname, | ||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | ||
sourceType: 'module', // Allows for the use of imports | ||
ecmaFeatures: { | ||
jsx: true // Allows for the parsing of JSX | ||
} | ||
}, | ||
rules: { | ||
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs | ||
// e.g. "@typescript-eslint/explicit-function-return-type": "off", | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
|
||
// These rules don't add much value, are better covered by TypeScript and good definition files | ||
'react/no-direct-mutation-state': 'off', | ||
'react/no-deprecated': 'off', | ||
'react/no-string-refs': 'off', | ||
'react/require-render-return': 'off', | ||
|
||
// we want to check ".tsx" files | ||
'react/jsx-filename-extension': [ | ||
'warn', | ||
{ | ||
extensions: ['.jsx', '.tsx'] | ||
} | ||
], | ||
'react/prop-types': 'off' // Is this incompatible with TS props type? | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use | ||
} | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
semi: true, | ||
trailingComma: 'all', | ||
singleQuote: true, | ||
printWidth: 120, | ||
tabWidth: 4, | ||
}; |
9 changes: 9 additions & 0 deletions
9
examples/fork-ts-checker-webpack-plugin/.vscode/settings.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"eslint.autoFixOnSave": false, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
{ "language": "typescript", "autoFix": true }, | ||
{ "language": "typescriptreact", "autoFix": true } | ||
] | ||
} |
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
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
4 changes: 1 addition & 3 deletions
4
examples/fork-ts-checker-webpack-plugin/src/components/layout.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
export const Layout: React.SFC<{}> = _props => ( | ||
<h1>Heya, heya, heya!!</h1> | ||
); | ||
export const Layout: React.SFC = _props => <h1>Heya, heya, heya!!</h1>; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,26 @@ | ||
{ | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.tsx" | ||
], | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": false, | ||
"target": "es5", | ||
"downlevelIteration": true, | ||
"importHelpers": true, | ||
"sourceMap": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"jsx": "react", | ||
"allowJs": false, | ||
"checkJs": false, | ||
"lib": [ | ||
"dom", | ||
"es2015", | ||
"es2016", | ||
"es2017", | ||
"esnext" | ||
], | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"noImplicitAny": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": false, | ||
"suppressImplicitAnyIndexErrors": true | ||
} | ||
} | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": false, | ||
"target": "es5", | ||
"downlevelIteration": true, | ||
"importHelpers": true, | ||
"sourceMap": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"jsx": "react", | ||
"allowJs": false, | ||
"checkJs": false, | ||
"lib": ["dom", "es2015", "es2016", "es2017", "esnext"], | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"noImplicitAny": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": false, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"types": ["jest"] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
1 change: 1 addition & 0 deletions
1
examples/fork-ts-checker-webpack-plugin/webpack.config.production.js
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
Oops, something went wrong.