forked from frontity/frontity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-staged.js
More file actions
29 lines (28 loc) · 764 Bytes
/
lint-staged.js
File metadata and controls
29 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const lintStaged = require("lint-staged");
/**
* Run lint-staged programatically to catch the errors because we don't want
* eslint errors to prevent the commit. Eslint will be checked again using a
* GitHub action once the code is pushed.
*
* We use two separate lint-staged executions to prevent lint-staged from
* reverting the prettier changes if eslint fails.
*/
(async () => {
try {
await lintStaged({
allowEmpty: true,
config: {
"*.{js,jsx,ts,tsx}": ["prettier --write", "git add"],
},
});
await lintStaged({
allowEmpty: true,
config: {
"*.{js,jsx,ts,tsx}": ["eslint --fix", "git add"],
},
});
} catch (e) {
// Failed to load configuration.
console.error(e);
}
})();