mhatch
mhatch

Reputation: 4605

eslint keyword errors on module.exports

I am getting the following strange errors from eslint CI for my jest.config.js file.

  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. This is the full jest.config.js file:

/* 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?

Upvotes: 0

Views: 1043

Answers (1)

dcwither
dcwither

Reputation: 961

ESLint reports config errors as an issue with the first line of files it's applied to. As @sleepwalker mentioned it should have to do with your eslint config (e.g. .eslingrc).

Looking up the first rule that is failing: no-empty-label.

It has the following warning:

This rule was removed in ESLint v2.0 and replaced by the no-labels rule.

So it's likely you need to follow the error recommendations, and make those modifications to your ESLint config.

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.

Upvotes: 2

Related Questions