我正在 React.JS 中编写一个小项目。每次我运行npm run start
时,它都会记录以下内容:
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
Watching: /Users/John/Projects/myProject/src
Starting the development server...
ts-loader: Using typescript@2.9.2 and /Users/John/Projects/myProject/tsconfig.json
Compiled successfully!
You can now view book-viewer-test in the browser.
Local: http://localhost:3000/
我用错误突出显示了该行。一切正常,但恐怕当项目变得更大和更复杂时,它可能会起作用。
这是什么警告/错误?我该如何解决?
这是我的 tsconfig.json 文件:
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es7", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
]
}
还有 tslint.json 文件:
{
"jsRules": {
"no-empty": true
}
}
感谢您的意见。
最佳答案
您仅有的TSLint规则适用于JavaScript文件,而不适用于TypeScript。为了整理TypeScript文件,请使用rules
而不是jsRules
。
{
"rules": {
"no-empty": true
}
}