Skip to content

Commit e3bf75c

Browse files
authored
[UIE-106] Avoid warning when committing JS files ignored by ESLint (#4071)
1 parent 8963006 commit e3bf75c

6 files changed

+39
-5
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ public
1212
node_modules
1313
.vscode
1414
coverage
15+
lint-staged.config.mjs

.pnp.cjs

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

lint-staged.config.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import process from 'process';
4+
5+
import ignore from 'ignore';
6+
7+
export default {
8+
'*.{js,ts}': (files) => {
9+
const cwd = process.cwd();
10+
const relativePaths = files.map((p) => path.relative(cwd, p));
11+
12+
const eslintIgnore = ignore().add(fs.readFileSync('.eslintignore').toString())
13+
const filesToLint = eslintIgnore.filter(relativePaths)
14+
if (filesToLint.length === 0) {
15+
return []
16+
}
17+
18+
return [`yarn eslint --max-warnings=0 ${filesToLint.join(' ')}`];
19+
},
20+
};

package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"eslint-plugin-react-hooks": "^4.6.0",
107107
"eslint-plugin-simple-import-sort": "^7.0.0",
108108
"husky": "^7.0.2",
109+
"ignore": "^5.2.4",
109110
"jest-axe": "^6.0.0",
110111
"jest-fail-on-console": "^3.1.1",
111112
"lint-staged": "^13.0.3",
@@ -153,10 +154,5 @@
153154
"jest": {
154155
"clearMocks": true,
155156
"resetMocks": false
156-
},
157-
"lint-staged": {
158-
"**/*.{js,ts}": [
159-
"yarn eslint --max-warnings=0"
160-
]
161157
}
162158
}

yarn.lock

+8
Original file line numberDiff line numberDiff line change
@@ -8710,6 +8710,13 @@ __metadata:
87108710
languageName: node
87118711
linkType: hard
87128712

8713+
"ignore@npm:^5.2.4":
8714+
version: 5.2.4
8715+
resolution: "ignore@npm:5.2.4"
8716+
checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef
8717+
languageName: node
8718+
linkType: hard
8719+
87138720
"igv@npm:2.11.2":
87148721
version: 2.11.2
87158722
resolution: "igv@npm:2.11.2"
@@ -15072,6 +15079,7 @@ __metadata:
1507215079
history: ^4.10.1
1507315080
husky: ^7.0.2
1507415081
iframe-resizer: ^4.3.2
15082+
ignore: ^5.2.4
1507515083
igv: 2.11.2
1507615084
jest-axe: ^6.0.0
1507715085
jest-fail-on-console: ^3.1.1

0 commit comments

Comments
 (0)