Skip to content

Commit

Permalink
chore(eslint): add eslint-webpack-plugin (#842)
Browse files Browse the repository at this point in the history
* added eslint webpack plugin

Signed-off-by: Max Cao <[email protected]>

* lint dirty modules only

Signed-off-by: Max Cao <[email protected]>

* add eslint caching, remove lintDirtyModulesOnly

---------

Signed-off-by: Max Cao <[email protected]>
  • Loading branch information
maxcao13 authored Feb 2, 2023
1 parent 0d9cf60 commit ba2e210
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ stats.json
coverage
storybook-static
.build_cache
.eslintcache
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"test": "jest --maxWorkers=50% --coverage=true",
"test:ci": "jest --maxWorkers=50%",
"eslint": "npm-run-all eslint:check",
"eslint:check": "eslint --ext .ts,.tsx,.js ./src/",
"eslint:apply": "eslint --ext .ts,.tsx,.js --fix ./src/",
"eslint:check": "eslint --cache --ext .ts,.tsx,.js ./src/",
"eslint:apply": "eslint --cache --ext .ts,.tsx,.js --fix ./src/",
"license:check": "license-check-and-add check -f license-config.json",
"license:apply": "license-check-and-add add -f license-config.json",
"lint": "npm-run-all -l -p format eslint",
Expand Down Expand Up @@ -54,6 +54,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-webpack-plugin": "^3.2.0",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^7.3.0",
"html-webpack-plugin": "^5.5.0",
Expand Down
12 changes: 6 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
}
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.jsx",
"**/*.js",
"**/*.json"
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.jsx",
"src/**/*.js",
"src/**/*.json"
],
"exclude": ["node_modules"]
"exclude": ["node_modules", "dist"]
}
7 changes: 7 additions & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const DotenvPlugin = require('dotenv-webpack');
const ESLintPlugin = require('eslint-webpack-plugin');

const HOST = process.env.HOST || "localhost";
const PORT = process.env.PORT || "9000";
Expand All @@ -19,6 +20,12 @@ module.exports = merge(common('development'), {
},
plugins: [
new DotenvPlugin(),
new ESLintPlugin({
cache: true,
cacheLocation: path.resolve(__dirname, '.eslintcache'),
extensions: ['js', 'jsx', 'ts', 'tsx'],
exclude: ['node_modules', 'dist'],
}),
],
module: {
rules: [
Expand Down
32 changes: 30 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ __metadata:
languageName: node
linkType: hard

"@types/eslint@npm:*":
"@types/eslint@npm:*, @types/eslint@npm:^7.29.0 || ^8.4.1":
version: 8.4.10
resolution: "@types/eslint@npm:8.4.10"
dependencies:
Expand Down Expand Up @@ -3389,6 +3389,7 @@ __metadata:
eslint-plugin-react: ^7.32.2
eslint-plugin-react-hooks: ^4.6.0
eslint-plugin-unused-imports: ^2.0.0
eslint-webpack-plugin: ^3.2.0
file-loader: ^6.2.0
fork-ts-checker-webpack-plugin: ^7.3.0
html-webpack-plugin: ^5.5.0
Expand Down Expand Up @@ -4685,6 +4686,22 @@ __metadata:
languageName: node
linkType: hard

"eslint-webpack-plugin@npm:^3.2.0":
version: 3.2.0
resolution: "eslint-webpack-plugin@npm:3.2.0"
dependencies:
"@types/eslint": ^7.29.0 || ^8.4.1
jest-worker: ^28.0.2
micromatch: ^4.0.5
normalize-path: ^3.0.0
schema-utils: ^4.0.0
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
webpack: ^5.0.0
checksum: 095034c35e773fdb21ec7e597ae1f8a6899679c290db29d8568ca94619e8c7f4971f0f9edccc8a965322ab8af9286c87205985a38f4fdcf17654aee7cd8bb7b5
languageName: node
linkType: hard

"eslint@npm:^8.33.0":
version: 8.33.0
resolution: "eslint@npm:8.33.0"
Expand Down Expand Up @@ -7166,6 +7183,17 @@ __metadata:
languageName: node
linkType: hard

"jest-worker@npm:^28.0.2":
version: 28.1.3
resolution: "jest-worker@npm:28.1.3"
dependencies:
"@types/node": "*"
merge-stream: ^2.0.0
supports-color: ^8.0.0
checksum: e921c9a1b8f0909da9ea07dbf3592f95b653aef3a8bb0cbcd20fc7f9a795a1304adecac31eecb308992c167e8d7e75c522061fec38a5928ace0f9571c90169ca
languageName: node
linkType: hard

"jest-worker@npm:^29.1.2":
version: 29.3.1
resolution: "jest-worker@npm:29.3.1"
Expand Down Expand Up @@ -7780,7 +7808,7 @@ __metadata:
languageName: node
linkType: hard

"micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4":
"micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5":
version: 4.0.5
resolution: "micromatch@npm:4.0.5"
dependencies:
Expand Down

0 comments on commit ba2e210

Please sign in to comment.