如此处所述,ESLint有一个关于缩进的属性叫做indent
。示例代码如下:
然而,如果我将这段代码粘贴到我的Or for tabbed indentation:
{ "indent": ["error", "tab"] }
.eslintrc
文件中,VS Code会提示出错:
我之前的ESLint: ESLint configuration in .eslintrc is invalid: - Unexpected top-level property "indent". . Please see the 'ESLint' output channel for details.
.eslintrc
文件已经有一些规则,没有打印出任何错误信息。如果我将"indent"
添加到该列表中或者单独使用它,就会失败。以下是在VS Code的ESLint输出通道中打印的错误和堆栈跟踪:
[Error - 10:38:55 PM] ESLint stack trace:
[Error - 10:38:55 PM] Error: ESLint configuration in .eslintrc is invalid:
- Unexpected top-level property "indent".
at validateConfigSchema (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/shared/config-validator.js:286:15)
at ConfigArrayFactory._normalizeConfigData (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/config-array-factory.js:469:9)
at ConfigArrayFactory._loadConfigDataInDirectory (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/config-array-factory.js:445:33)
at ConfigArrayFactory.loadInDirectory (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/config-array-factory.js:401:18)
at CascadingConfigArrayFactory._loadConfigInAncestors (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:305:46)
at CascadingConfigArrayFactory.getConfigArrayForFile (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:250:18)
at CLIEngine.executeOnText (/home/aaronfranke/workspace/OddJobs/node_modules/eslint/lib/cli-engine/cli-engine.js:860:47)
at /home/aaronfranke/.vscode/extensions/dbaeumer.vscode-eslint-1.9.1/server/out/eslintServer.js:1:60107
at /home/aaronfranke/.vscode/extensions/dbaeumer.vscode-eslint-1.9.1/server/out/eslintServer.js:1:61116
发生了什么?这个选项不可用吗?示例配置有误吗?我的ESLint扩展有问题吗?VS Code有问题吗?我正在使用Ubuntu 18.04 Linux 64位操作系统,VS Code 1.40.1版本,ESLint扩展1.9.1版本,eslint --version
的输出是v5.16.0
。