我.eslintignore就在旁边eslintrc.js
忽略的原因很简单:
.eslintrc.js
dist/*
node_modules/*
out-tsc/*
Run Code Online (Sandbox Code Playgroud)
但是,当我进入时,eslintrc.js我收到此错误:
Parsing error: ESLint was configured to run on `<tsconfigRootDir>/.eslintrc.js` using `parserOptions.project`: <tsconfigRootDir>/../../../../../../users/dstein/repositories/social-experiment/packages/site/tsconfig.json
However, that TSConfig does not include this file. Either:
- Change ESLint's list of included files to not include this file
- Change that TSConfig to include this file
- Create a new TSConfig that includes this file and include it in your parserOptions.project
See the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
Run Code Online (Sandbox Code Playgroud)
不出所料,它链接到的文章说,.eslintignore如果您不想对错误所在的文件进行 lint …
今天我运行 eslint?two 脚本
"lint-staged": "lint-staged",
"eslint": "eslint --ext .tsx,.ts --fix ./src -c .eslintrc.js",
Run Code Online (Sandbox Code Playgroud)
当我运行时npm run eslint// 没关系 当我运行时npm run lint-staged// 它是错误的
lint-staged 的结果;
> lint-staged
? Running tasks for src/**/*.tsx
? eslint --fix [FAILED]
? git add
? eslint --fix :
Oops! Something went wrong! :(
ESLint: 7.10.0
Error: Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for …Run Code Online (Sandbox Code Playgroud) 我不确定为什么会出现此错误
You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project"
Run Code Online (Sandbox Code Playgroud)
这是我的配置
tsconfig
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"rootDir": "src",
"baseUrl": "src",
"paths": {
"@/*": [
"*"
]
},
"allowJs": true,
"resolveJsonModule": true
},
"include": [
"src"
],
"exclude": [
"src/main/test/cypress"
]
}
Run Code Online (Sandbox Code Playgroud)
.eslintrc.json
{
"extends": "standard-with-typescript",
"parserOptions": {
"projects": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/consistent-type-definitons": "off", …Run Code Online (Sandbox Code Playgroud) 我想指定要在 eslintrc.js 中检查哪些文件,因此我添加了文件:...
module.exports = {
extends: [
'react-app',
'react-app/jest',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
files: ['*.ts', '*.jsx', '*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'testing-library/no-node-access': 'off',
},
};
Run Code Online (Sandbox Code Playgroud)
但是当我的预提交运行时出现以下错误:
precommit: BABEL_ENV=development eslint src --ext .js,.jsx,.ts,.tsx --fix'*.ts', '*.tsx'
Error: ESLint configuration in .eslintrc.js is invalid:
- Unexpected top-level property "files".
Run Code Online (Sandbox Code Playgroud) 我有一个使用 eslint 和 prettier 设置的 Angular 10 应用程序,到目前为止它可以很好地处理 Typescript 文件。我现在正在尝试按照此文档整理我的组件模板文件。
但是当我运行它时,eslint . --ext .js,.ts,.component.html --fix我不断得到
Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Run Code Online (Sandbox Code Playgroud)
我的.eslintrc.js看起来像这样(注意本overrides节中的第二个块):
module.exports = {
extends: [
"plugin:@angular-eslint/recommended",
// For spec files
"plugin:jasmine/recommended",
// AirBnB Styleguide rules
"airbnb-typescript/base",
// Settings for Prettier
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
],
plugins: [
"prettier",
"jasmine",
], …Run Code Online (Sandbox Code Playgroud) 我想用 CSS 模块 + SASS 构建一个项目。我想要一些全局样式(mixins、变量、函数等),这些样式在每个 component.module.scss 中都可用。为此,我需要将全局样式导入到每个模块样式文件中。由于我预计会有很多组件,因此我一直在寻找自动执行此操作的选项。我发现sass-resourcess-loader可能会有所帮助。
然而,由于我没有任何使用 Webpack 的经验,所以我在设置它时遇到了麻烦。
到目前为止我做了什么:
{ test: /.scss$/, use: [ { loader: "style-loader", }, { loader: "css-loader", }, { loader: "sass-loader", }, { loader: "sass -资源加载器", } ], }
抱歉,我无法以某种方式正确设置该代码片段的样式。我也尝试过选项字段:
options: {
resources: "./src/global.scss"
}
Run Code Online (Sandbox Code Playgroud)
但没有任何效果,我的模块化 scss 文件中仍然出现未定义的变量。
我究竟做错了什么?或者有其他方法可以解决这个问题吗?
当我打开.vue文件时,我的 IntelliJ IDEA 中出现以下错误:
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: XX\XX\CurrentFile.vue.
The file must be included in at least one of the projects provided.
Run Code Online (Sandbox Code Playgroud)
当然,如果你教我解决方案,我会很高兴,但首先我知道它意味着什么以及为什么会出现。
我怀疑这是某种错误或不准确的错误消息。实验上已知:
eslint从控制台运行某个.vue文件,eslint 将正确完成执行。所以看起来它不是 eslint 错误。我的 Eslint 配置(YAML):
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: XX\XX\CurrentFile.vue.
The file must be included in at least …Run Code Online (Sandbox Code Playgroud) eslint ×5
typescript ×4
javascript ×2
angular ×1
css ×1
eslintrc ×1
husky ×1
lint-staged ×1
reactjs ×1
sass ×1
vue.js ×1
webpack ×1
webpack-4 ×1