I have an expo project that uses typescript, originally generated via
expo init myApp --template @native-base/expo-template-typescript
I added husky and have a lint staged definition that simply says this:
"lint-staged": {
"*.{js,jsx}": [
"eslint --cache --fix"
],
"*.{ts,tsx}": [
"tsc --project tsconfig.json",
"eslint --cache --fix"
]
},
When tsc runs via the pre-commit hook this way it incorrectly checks the node_modules files, and also generates.js files of all the.tsx files that were checked in my src
dir. However, running the following simple package.json command via yarn lint
does not do those incorrect actions
"scripts": {
...
"lint": "eslint './src/**/*{js,ts,jsx,tsx}' --fix && tsc",
...
},
Add --noEmit
to prevent JavaScript from being generated.
"scripts": {
...
"lint": "eslint './src/**/*{js,ts,jsx,tsx}' --fix && tsc --noEmit",
...
},
Perhaps this is already setup by the tsconfig.json
so --project tsconfig.json
might also work:
"scripts": {
...
"lint": "eslint './src/**/*{js,ts,jsx,tsx}' --fix && tsc --project tsconfig.json",
...
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.