Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit a8f3aab

Browse files
Added ability to parse JS files with tsconfig
- make eslint scripts run per file & add that to lint-staged
1 parent 91bd9a8 commit a8f3aab

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
internals/scripts
2+
internals/generators
3+
server/
24
**/types.d.ts
35
*.html

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
ecmaFeatures: {
2222
jsx: true,
2323
},
24-
project: './tsconfig.json',
24+
project: './tsconfig.eslint.json',
2525
},
2626
rules: {
2727
'jsx-no-lambda': 0,

docs/general/commands.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,22 @@ about the bundle size.
136136

137137
## Linting
138138

139+
To lint all source files js, ts & css files run
140+
139141
```Shell
140142
npm run lint
141143
```
142144

143-
Lints your JavaScript and your CSS.
145+
To lint individual js, ts, jsx, tsx file run
146+
147+
```Shell
148+
npm run lint:eslint <file-path>
149+
```
150+
151+
To lint & fix staged files run
144152

145153
```Shell
146-
npm run lint:eslint:fix -- .
154+
npx lint-staged
147155
```
148156

149157
Lints your code and tries to fix any errors it finds.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"clean": "shjs ./internals/scripts/clean.js",
3232
"clean:all": "npm run analyze:clean && npm run test:clean && npm run build:clean",
3333
"generate": "plop --plopfile internals/generators/index.js",
34-
"lint": "npm run lint:css && npm run lint:eslint:quiet",
34+
"lint": "npm run lint:css && npm run lint:eslint:quiet app/**",
3535
"lint:css": "stylelint './app/**/*.{js,ts}'",
36-
"lint:eslint:quiet": "eslint app/** --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern --quiet",
37-
"lint:eslint": "eslint app/** --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern",
38-
"lint:eslint:fix": "eslint app/** --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern --quiet --fix",
36+
"lint:eslint:quiet": "eslint --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern --quiet",
37+
"lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern",
38+
"lint:eslint:fix": "eslint --ext .ts,.tsx,.js,.jsx --no-error-on-unmatched-pattern --quiet --fix",
3939
"typecheck": "tsc --noEmit",
4040
"pretest": "npm run test:clean && npm run lint",
4141
"test:clean": "rimraf ./coverage",
@@ -45,8 +45,8 @@
4545
"prettify": "prettier --write"
4646
},
4747
"lint-staged": {
48-
"*.{ts,tsx}": [
49-
"eslint --fix --quiet",
48+
"*.{ts,tsx,js,jsx}": [
49+
"npm run lint:eslint:fix",
5050
"git add --force"
5151
],
5252
"*.{md,json}": [
@@ -56,7 +56,7 @@
5656
},
5757
"husky": {
5858
"hooks": {
59-
"pre-commit": "npm run lint"
59+
"pre-commit": "npx lint-staged && npm run typecheck"
6060
}
6161
},
6262
"resolutions": {

tsconfig.eslint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
// extend your base config so you don't have to redefine your compilerOptions
3+
"extends": "./tsconfig.json",
4+
"include": [
5+
"app/**/*.ts",
6+
"app/**/*.tsx",
7+
"app/**/*.js",
8+
"app/**/*.jsx",
9+
"internals/**/*.js",
10+
"internals/**/*.jsx"
11+
]
12+
}

0 commit comments

Comments
 (0)