google / eslint-config-google

ESLint shareable config for the Google JavaScript style guide
Apache License 2.0
1.74k stars 140 forks source link

[error] Definition for rule 'switch-colon-spacing' was not found #47

Closed gastonche closed 6 years ago

gastonche commented 7 years ago

I am using eslint-config-google, for my styles with eslint and I keep getting an error for all the files I am linting 1:1 error Definition for rule 'switch-colon-spacing' was not found

My .eslintrc this:

{
  "parser": "babel-eslint",
  "parserOptions": {
    "sourceType": "module",
    "allowImportExportEverywhere": false,
    "codeFrame": false,
    "ecmaFeatures": {
      "jsx": true,
      "modules": true,
      "spread" : true,
      "restParams" : true
    }
  },
  "extends": ["eslint:recommended", "plugin:react/recommended", "google"],
  "globals": {
    "require": true,
    "module": true
  },
  "rules": {
    "strict": 1,
    "comma-spacing":1,
    "no-console":0,
    "indent": ["error", 2],
    "switch-colon-spacing": [
      "error", 
      {
        "after": true, 
        "before": false
      }
    ]
  },
  "env":{
    "es6": true,        // We are writing ES6 code
    "browser": true,    // for the browser
    "commonjs": true    // and use require() for stylesheets
  },
  "plugins": [
    "react"
  ]
}

I am unable to see what's wrong here

philipwalton commented 7 years ago

My guess is you're using a pre-4.0 version of eslint, which is when that rule was added. Without knowing more about your setup, it's impossible to say.

ghost commented 7 years ago

@gastonche

If you have not found a solution for this I updated out .eslintrc.yml to the following as we are not really interested in using the rule in our lint configuration. See snippet below:

extends: 
  - google
parser: "babel-eslint"
parserOptions:
  emcaVersion: 6
  sourceType: module
  emcaFeatures:
    modules: true
rules:
  switch-colon-spacing: 0

Options below: Severity should be one of the following: 0 = off, 1 = warn, 2 = error.

tylerwray commented 6 years ago

@philipwalton @gastonche I was working in a repo that had version 3 of eslint, upgrading to eslint 4 fixed the issue!