[英]eslint keyword errors on module.exports
I am getting the following strange errors from eslint CI for my jest.config.js file.对于我的 jest.config.js 文件,我从 eslint CI 收到以下奇怪的错误。
1:1 error Rule 'no-empty-label' was removed and replaced by: no-labels no-empty-label
1:1 error Rule 'no-reserved-keys' was removed and replaced by: quote-props no-reserved-keys
1:1 error Rule 'space-after-keywords' was removed and replaced by: keyword-spacing space-after-keywords
1:1 error Rule 'space-return-throw-case' was removed and replaced by: keyword-spacing space-return-throw-case
They seem to be complaining about some js keyword, although I cannot see any.他们似乎在抱怨一些 js 关键字,尽管我看不到任何关键字。 This is the full jest.config.js file:这是完整的 jest.config.js 文件:
/* global module */
module.exports = {
roots: [
'<rootDir>/src'
],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.d.ts'
],
setupFiles: [
'react-app-polyfill/jsdom'
],
setupFilesAfterEnv: [
'<rootDir>/src/setupTests.js'
],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'
],
testEnvironment: 'jest-environment-jsdom-fourteen',
testPathIgnorePatterns: [
'<rootDir>/src/__tests__/specHelpers/',
'<rootDir>/src/__tests__/mocks/'
],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js'
},
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$'
],
modulePaths: [
'<rootDir>/src'
],
moduleNameMapper: {
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy'
},
moduleFileExtensions: [
'web.js',
'js',
'web.ts',
'ts',
'web.tsx',
'tsx',
'json',
'web.jsx',
'jsx',
'node'
],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
]
};
Does anybody see what eslint is complaining about?有人看到 eslint 在抱怨什么吗?
ESLint reports config errors as an issue with the first line of files it's applied to. ESLint 将配置错误报告为它应用到的第一行文件的问题。 As @sleepwalker mentioned it should have to do with your eslint config (eg .eslingrc
).正如@sleepwalker 提到的,它应该与您的 eslint 配置(例如.eslingrc
)有关。
Looking up the first rule that is failing: no-empty-label
.查找第一条失败的规则: no-empty-label
。
It has the following warning:它有以下警告:
This rule was removed in ESLint v2.0 and replaced by the no-labels rule.此规则在 ESLint v2.0 中被移除并被无标签规则取代。
So it's likely you need to follow the error recommendations, and make those modifications to your ESLint config.因此,您可能需要遵循错误建议,并对 ESLint 配置进行这些修改。
Example:例子:
- "no-empty-label": "error"
+ "no-labels": "error"
or if you want the exact same behavior (meaning you do want labels in specific cases):或者如果您想要完全相同的行为(这意味着您确实需要在特定情况下使用标签):
- "no-empty-label": "error"
+ "no-labels": ["error", { "allowLoop": true, "allowSwitch": true }]
It's also possible these rules are coming from a config you're extending, so you may have to look at either removing, overriding, or updating that config.这些规则也可能来自您正在扩展的配置,因此您可能需要考虑删除、覆盖或更新该配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.