我使用neovim开发TypeScript,我升级了eslint 8.28.0 当我打开neovim时出现错误,我尝试了很多次解决,但仍然无法解决这个问题,请寻求帮助
\n\xe2\x9d\xb4eslint_d\xe2\x9d\xb5 [eslint] Error: Failed to load plugin \'import declared in \'.eslintrc.js \xc2\xbb eslint-config-semistandard \xc2\xbb\n eslint-config-standard\': Cannot find module \'eslint\' Require stack: \n - /Users/jornajan/Coding/bilibili/muke/miProject/node_modules/eslint-plugin-import/lib/ExportMap.js \n - /Users/jornajan/Coding/bilibili/muke/miProject/node_modules/eslint-plugin-import/lib/rules/named.js\n
Run Code Online (Sandbox Code Playgroud)\n$ node -v\n18.12.1\n\n$ npm -v\n9.1.3\n
Run Code Online (Sandbox Code Playgroud)\n怎么解决这个问题,不知道是不是bug
\n我知道有很多这样的答案,这个或者会将我的问题标记为重复,但相信我,我正在努力解决这个问题,因为他们现在都不适合我。这些解决方案之前可以工作,但看起来该解决方案已折旧或过期。
我对 eslint 一无所知,我唯一喜欢 eslint 的是它用红线强调了未导入/未声明的变量,这就是我在 VS Code 编辑器中安装 eslint 扩展的原因。
另外,我没有直接在 VS Code 中打开代码目录,我在同一工作区中也有其他项目,例如我有这样的结构:
| -- some_folder
| | -- project_1
| | -- project_2
| ...files relating to both projects...
Run Code Online (Sandbox Code Playgroud)
启动一个新的 Next.js 项目不应该出现任何错误,不知道我做错了什么。
这是我的.eslintrc.json
:
{
"extends": "next"
}
Run Code Online (Sandbox Code Playgroud)
这是.babelrc
:
{
"presets": ["next/babel"],
"plugins": []
}
Run Code Online (Sandbox Code Playgroud)
为了准确说明我已经尝试过的解决方案类型:
next/babel
在.eslintrc.json
babel-eslint
但没有任何帮助!我有一个超级秘密变量SUPERBASE_PRIVATE_SERVICE_ROLE
,我不希望我的开发人员在除特定位置之外的任何地方使用它。
我正在尝试使用这个规则:
"no-restricted-properties": [
"error",
{
"object": "process",
"property": "env.SUPERBASE_PRIVATE_SERVICE_ROLE",
"message": "Usage of process.env.SUPERBASE_PRIVATE_SERVICE_ROLE is not allowed."
}
]
Run Code Online (Sandbox Code Playgroud)
但这失败了,有人可以告诉我出了什么问题或者有什么方法可以限制它吗?
假设我要使用以下规则:
https://eslint.org/docs/rules/no-debugger
但是,我有大约15个文件要保留调试器。陈述。
我可以在.ts / .js文件的顶部添加一些内容,以使ESLint忽略no-debugger
此特定文件的规则吗?
我有一个类似于以下的文件夹结构:
/root
.eslintrc.json
package.json
/someFolder
/sub
/sub
/anotherFolder
/src
/containers
/components
/oneMoreFolder
/sub
/sub
Run Code Online (Sandbox Code Playgroud)
我正在使用create-react-app并正在使用airbnb规则。我已经能够从CLI轻松地在特定文件夹中运行linter,但在编译时,它针对所有文件夹。
我只想在/ src文件夹中的文件上运行linter 。
我该怎么办?我已经尝试了多种解决方案。
谢谢!
TL:DR使用eslint和create-react-app时,如何只针对一个子文件夹及其所有文件进行编译?
reactjs eslint airbnb-js-styleguide create-react-app eslintrc
我今天上班时遇到了来自我的 linter 包的异常错误。我查看了该包的文档,但我看不到 eslintrc 文件有任何问题。
这是我正在使用的内容的副本
{
"extends": "airbnb",
"parser": "babel-eslint",
"rules": {
"import/no-extraneous-dependencies": "off",
"import/extensions": "off",
"import/no-unresolved": "off",
"eol-last": "off",
"no-unused-expressions": ["error",{
"allowTernary": true,
"allowShortCircuit": true
}],
"react/jsx-indent-props": "off",
"react/jsx-indent" : ["error", 4, { "props": 4 }],
"indent": [ "error", 4],
"react/jsx-filename-extension": "off",
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": [],
"specialLink": [
"hrefLeft",
"hrefRight"
],
"aspects": [
"noHref",
"invalidHref",
"preferButton"
]
}
],
"no-bitwise": "off"
},
"env": {
"browser": true,
"jest": true
}
Run Code Online (Sandbox Code Playgroud)
}
当我从命令行运行 eslint 时,我没有遇到任何问题,这使得这更加令人困惑!
任何帮助将不胜感激 :)
当我require
在 JavaScript 中使用时,我收到来自 eslint 的警告,“require is not defined eslint(no-undef)”。
除了这个文件,我项目中的所有文件都使用浏览器env
,这是在我的.eslintrc
.
我怎样才能例外并为这个文件指定一个节点环境?
var fs = require('fs');
var path = require('path');
// my code
Run Code Online (Sandbox Code Playgroud) 我一直在尝试谷歌搜索上的所有结果作为可能的解决方案,但到目前为止没有任何运气。
每当我运行npm run vue-cli-service serve --port 1024
我的 vue 项目(使用 vue cli 创建)时,我都会收到错误node_modules
4111:10 Type alias 'MergeList' circularly references itself.
4109 | @hidden
4110 | */
> 4111 | type MergeList<O, Path extends List<Key>, O1 extends object, depth extends Depth, I extends Iteration = IterationOf<'0'>> = O extends object ? O extends (infer A)[] ? MergeList<A, Path, O1, depth, I>[] : Pos<I> extends Length<Path> ? OMerge<O, O1, depth> : {
| ^
4112 | [K in keyof O]: …
Run Code Online (Sandbox Code Playgroud) 我正在 Angular 11 项目中工作。这个项目中的很多导入都使用相对路径或绝对路径。
我为这个项目设置了 ESLint,我想阻止相对导入路径,只允许绝对路径。但我没有找到这样做的规则。
我发现:no-relative-parent-imports,但它没有给我这样的路径问题:import { HttpService } from "../http/http.service";
或import { RouterService } from "../../services/router/router.service";
(两者都不是绝对路径,它们的绝对路径分别是import { HttpService } from "app/services/http/http.service";
和import { RouterService } from "app/services/router/router.service";
。
我读过这篇文章:https : //medium.com/@aayush123/escaping-relative-import-hell-react-native-eslint-atom-57dc2cae5bcc
但我想避免添加像 Babel 这样的东西,如果我可以避免的话.
ESLint 是否有阻止任何类型的相对路径的规则?只允许绝对路径?
我有以下情况eslintrc.js
:
module.exports = {
extends: ['airbnb-typescript/base'],
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
},
ignorePatterns: ['*.js'],
rules: {
'no-underscore-dangle': 0,
...
}
};
Run Code Online (Sandbox Code Playgroud)
我想包括一些例外情况allow: [ /** */ ]
。但是每次当我将其添加为文件中的 key: value 属性时,ESLint 都会返回一个错误,其中包含以下文本:unable to use allow on top level
。那么问题来了,如何用allow来达到这样的结果呢?
长话短说,我无法将我的规则集与 MongoDB_id
命名一起使用,因此我使用 ESLint 仅忽略_id
变量命名,而不是禁用命名约定规则本身。
有什么办法可以解决这个问题吗?
eslint ×10
eslintrc ×10
eslintignore ×2
javascript ×2
typescript ×2
angular ×1
angular11 ×1
babel-eslint ×1
neovim ×1
next.js ×1
reactjs ×1
vue.js ×1