codeclimate-eslint icon indicating copy to clipboard operation
codeclimate-eslint copied to clipboard

Error in codeclimate: Configuration for rule "import/order" is invalid

Open SalmaKhater opened this issue 3 years ago • 10 comments

Bug Template

Hey, I am having the issues with @typescript-eslint on codeclimate. Locally eslint works fine but it raises an error when running on codeclimate: Configuration for rule "import/order" is invalid.

Actual Behavior

No rules are configured. Make sure you have added a config file with rules enabled.
See our documentation at https://docs.codeclimate.com/docs/eslint for more information.
No rules are configured. Make sure you have added a config file with rules enabled.
See our documentation at https://docs.codeclimate.com/docs/eslint for more information.
No rules are configured. Make sure you have added a config file with rules enabled.
See our documentation at https://docs.codeclimate.com/docs/eslint for more information.
No rules are configured. Make sure you have added a config file with rules enabled.
See our documentation at https://docs.codeclimate.com/docs/eslint for more information.
Module not supported: prefer-arrow
/usr/local/node_modules/eslint/lib/shared/config-validator.js:138
            throw new Error(`${source}:\n\t${enhancedMessage}`);
            ^

Error: .eslintrc.js:
	Configuration for rule "import/order" is invalid:
	Value {"alphabetize":{"order":"asc","caseInsensitive":true},"groups":["external","builtin","index","sibling","parent","internal","object"]} should NOT have additional properties.

    at validateRuleOptions (/usr/local/node_modules/eslint/lib/shared/config-validator.js:138:19)
    at /usr/local/node_modules/eslint/lib/shared/config-validator.js:193:9
    at Array.forEach (<anonymous>)
    at validateRules (/usr/local/node_modules/eslint/lib/shared/config-validator.js:190:30)
    at validateConfigArray (/usr/local/node_modules/eslint/lib/shared/config-validator.js:337:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (/usr/local/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:392:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/usr/local/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:248:21)
    at FileEnumerator._iterateFilesWithFile (/usr/local/node_modules/eslint/lib/cli-engine/file-enumerator.js:321:43)
    at FileEnumerator._iterateFiles (/usr/local/node_modules/eslint/lib/cli-engine/file-enumerator.js:302:25)
    at FileEnumerator.iterateFiles (/usr/local/node_modules/eslint/lib/cli-engine/file-enumerator.js:254:59)

Expected Behavior

I expect to build to pass

Steps to reproduce

.codeclimate.yml

version: "2"
checks:
  argument-count:
    config:
      threshold: 8
  complex-logic:
    config:
      threshold: 10
  file-lines:
    config:
      threshold: 1000
  method-complexity:
    config:
      threshold: 10
  method-count:
    config:
      threshold: 20
  method-lines:
    config:
      threshold: 50
  nested-control-flow:
    config:
      threshold: 4
  return-statements:
    config:
      threshold: 4
  similar-code:
    enabled: false
    config:
      threshold: # language-specific defaults. an override will affect all languages.
  identical-code:
    enabled: true
    config:
      threshold: # language-specific defaults. an override will affect all languages.
plugins:
  eslint:
    enabled: true
    channel: "eslint-6"
  config:
    config: tsconfig.json
    extensions:
    - .js
    - .ts
  fixme:
    enabled: true
    config:
      strings:
      - FIXME
      - BUG
      - TODO
ratings:
  paths:
    - "src/**/*.ts"
exclude_patterns:
  - ".circleci/"
  - "__mocks__/"
  - "**/tests/"
  - "src/**/*.spec.ts"
  - "src/**/*.model.ts"
  - "docker/"
  - "node_modules/"
  - "**/documentation/"
  - "**/node_modules/"
  - "src/database/migrations/"
  - "src/seed.ts"
  - "src/scripts/"
  - "README.md"
  - "src/skill/fixtures.ts"
  - "src/shared/fixtures.ts"

.eslintrc

module.exports = {
  env: {
    browser: true,
    es6: true,
    node: true,
  },
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'plugin:import/errors',
    'plugin:import/warnings',
    'plugin:import/typescript',
    'prettier/@typescript-eslint',
    'plugin:prettier/recommended', //Make sure this is always the last configuration in the extends array
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.eslint.json',
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint', 'import', 'jsdoc', 'prefer-arrow'],
  settings: {
    'import/resolver': 'webpack',
  },
  rules: {
    '@typescript-eslint/adjacent-overload-signatures': 'error',
    '@typescript-eslint/array-type': 'off',
    '@typescript-eslint/await-thenable': 'off',
    '@typescript-eslint/ban-ts-comment': [
      'error',
      {
        'ts-ignore': false,
      },
    ],
    '@typescript-eslint/ban-types': [
      'error',
      {
        extendDefaults: false,
        types: {
          Object: {
            message: 'Avoid using the `Object` type. Did you mean `object`?',
          },
          Function: {
            message:
              'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
          },
          Boolean: {
            message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
          },
          Number: {
            message: 'Avoid using the `Number` type. Did you mean `number`?',
          },
          String: {
            message: 'Avoid using the `String` type. Did you mean `string`?',
          },
          Symbol: {
            message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
          },
        },
      },
    ],
    '@typescript-eslint/consistent-type-assertions': 'error',
    '@typescript-eslint/dot-notation': 'error',
    '@typescript-eslint/explicit-member-accessibility': [
      'off',
      {
        accessibility: 'explicit',
      },
    ],
    '@typescript-eslint/explicit-module-boundary-types': 'warn',
    '@typescript-eslint/member-delimiter-style': [
      'error',
      {
        multiline: {
          delimiter: 'semi',
          requireLast: true,
        },
        singleline: {
          delimiter: 'semi',
          requireLast: false,
        },
      },
    ],
    '@typescript-eslint/member-ordering': 'off',
    '@typescript-eslint/naming-convention': [
      'error',
      {
        selector: 'enumMember',
        format: ['PascalCase', 'UPPER_CASE'],
      },
    ],
    '@typescript-eslint/no-array-constructor': 'error',
    '@typescript-eslint/no-empty-function': [
      'error',
      {
        allow: ['constructors'],
      },
    ],
    '@typescript-eslint/no-empty-interface': 'error',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-extra-non-null-assertion': 'error',
    '@typescript-eslint/no-extra-semi': 'error',
    '@typescript-eslint/no-floating-promises': 'off',
    '@typescript-eslint/no-for-in-array': 'error',
    '@typescript-eslint/no-implied-eval': 'error',
    '@typescript-eslint/no-inferrable-types': 'error',
    '@typescript-eslint/no-misused-new': 'error',
    '@typescript-eslint/no-misused-promises': 'error',
    '@typescript-eslint/no-namespace': 'error',
    '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
    '@typescript-eslint/no-non-null-assertion': 'warn',
    '@typescript-eslint/no-parameter-properties': 'off',
    '@typescript-eslint/no-this-alias': 'error',
    '@typescript-eslint/no-unnecessary-type-assertion': 'error',
    '@typescript-eslint/no-unsafe-assignment': 'off', //TODO rule no-unsafe-assignment
    '@typescript-eslint/no-unsafe-call': 'off', //TODO enable no-unsafe-call rule
    '@typescript-eslint/no-unsafe-member-access': 'off', //TODO enable no-unsafe-member-access rule
    '@typescript-eslint/no-unsafe-return': 'off',
    '@typescript-eslint/no-unused-expressions': 'off',
    '@typescript-eslint/no-unused-vars': 'warn',
    '@typescript-eslint/no-use-before-define': 'off',
    '@typescript-eslint/no-var-requires': 'error',
    '@typescript-eslint/prefer-as-const': 'error',
    '@typescript-eslint/prefer-for-of': 'error',
    '@typescript-eslint/prefer-function-type': 'error',
    '@typescript-eslint/prefer-namespace-keyword': 'error',
    '@typescript-eslint/prefer-regexp-exec': 'off',
    '@typescript-eslint/quotes': ['off', 'single'],
    '@typescript-eslint/require-await': 'off',
    '@typescript-eslint/restrict-plus-operands': 'off',
    '@typescript-eslint/restrict-template-expressions': [
      'off',
      {
        allowNumber: true,
        allowBoolean: true,
        allowAny: true,
        allowNullish: false,
      },
    ],
    '@typescript-eslint/semi': ['error', 'always'],
    '@typescript-eslint/triple-slash-reference': [
      'error',
      {
        path: 'always',
        types: 'prefer-import',
        lib: 'always',
      },
    ],
    '@typescript-eslint/unbound-method': 'off',
    '@typescript-eslint/unified-signatures': 'error',
    'arrow-parens': ['off', 'always'],
    'brace-style': ['error', '1tbs'],
    complexity: 'off',
    'constructor-super': 'error',
    curly: 'off',
    'eol-last': 'error',
    eqeqeq: ['error', 'smart'],
    'guard-for-in': 'error',
    'id-blacklist': [
      'error',
      'any',
      'Number',
      'number',
      'String',
      'string',
      'Boolean',
      'boolean',
      'Undefined',
      'undefined',
    ],
    'id-match': 'error',
    'import/no-unresolved': 2,
    'import/order': [
      'error',
      {
        alphabetize: {
          order: 'asc',
          caseInsensitive: true,
        },
        groups: [
          'external',
          'builtin',
          'index',
          'sibling',
          'parent',
          'internal',
          'object',
        ],
      },
    ],
    'jsdoc/check-alignment': 'error',
    'jsdoc/check-indentation': [
      'error',
      {
        excludeTags: ['example', 'description'],
      },
    ],
    'jsdoc/newline-after-description': 'error',
    'max-classes-per-file': ['error', 1],
    'max-len': [
      'error',
      {
        code: 150,
        ignoreComments: true,
      },
    ],
    'max-lines': ['error', 500],
    'new-parens': 'error',
    'no-array-constructor': 'off',
    'no-bitwise': 'error',
    'no-caller': 'error',
    'no-cond-assign': 'error',
    'no-console': [
      'error',
      {
        allow: [
          'dir',
          'time',
          'timeEnd',
          'timeLog',
          'trace',
          'assert',
          'clear',
          'count',
          'countReset',
          'group',
          'groupEnd',
          'table',
          'debug',
          'dirxml',
          'groupCollapsed',
          'Console',
          'profile',
          'profileEnd',
          'timeStamp',
          'context',
        ],
      },
    ],
    'no-debugger': 'error',
    'no-empty': 'error',
    'no-empty-function': 'off',
    'no-eval': 'error',
    'no-extra-semi': 'off',
    'no-fallthrough': 'off',
    'no-invalid-this': 'off',
    'no-new-wrappers': 'error',
    'no-shadow': [
      'off',
      {
        hoist: 'functions',
      },
    ],
    'no-throw-literal': 'error',
    'no-trailing-spaces': 'error',
    'no-undef-init': 'error',
    'no-underscore-dangle': 'off',
    'no-unsafe-finally': 'error',
    'no-unused-labels': 'error',
    'no-unused-vars': 'off',
    'no-var': 'error',
    'object-shorthand': 'error',
    'one-var': ['off', 'never'],
    'prefer-arrow/prefer-arrow-functions': 'off',
    'prefer-const': 'error',
    'quote-props': ['error', 'as-needed'],
    radix: 'error',
    'require-await': 'off',
    'spaced-comment': [
      'error',
      'always',
      {
        markers: ['/'],
      },
    ],
    'use-isnan': 'error',
    'valid-typeof': 'off',
  },
};

package.json

{
  "engines": {
    "node": "12.x.x"
  },
  "engineStrict": true,
  "dependencies": {
    "@google-cloud/debug-agent": "5.1.2",
    "@google-cloud/pubsub": "2.1.0",
    "@google-cloud/storage": "5.1.1",
    "@google-cloud/tasks": "2.0.1",
    "@hapi/joi": "17.1.1",
    "@nest-middlewares/cors": "6.0.1",
    "@nest-middlewares/helmet": "6.0.0",
    "@nest-middlewares/response-time": "6.0.0",
    "@nestcloud/schedule": "0.7.5",
    "@nestjs/common": "7.3.1",
    "@nestjs/core": "7.3.1",
    "@nestjs/graphql": "7.5.1",
    "@nestjs/platform-express": "7.3.1",
    "@nestjs/platform-socket.io": "7.3.1",
    "@nestjs/swagger": "4.5.12",
    "@nestjs/testing": "7.3.1",
    "@nestjs/websockets": "7.3.1",
    "@okta/jwt-verifier": "1.0.0",
    "@reactivex/rxjs": "6.6.0",
    "@slack/web-api": "5.10.0",
    "@types/chance": "1.1.0",
    "@types/express-jwt": "0.0.42",
    "@types/jsforce": "^1.9.17",
    "@types/lodash": "4.14.157",
    "@types/node": "14.0.14",
    "accesscontrol": "2.2.1",
    "acorn": "^7.3.1",
    "apollo-server-express": "2.15.1",
    "async": "3.2.0",
    "axios": "0.19.2",
    "body-parser": "1.19.0",
    "body-parser-xml": "^2.0.0",
    "by-node-env": "2.0.1",
    "chance": "1.1.6",
    "chart.js": "2.9.3",
    "chartjs-node-canvas": "3.0.6",
    "class-transformer": "0.3.1",
    "class-validator": "0.12.2",
    "colors": "1.4.0",
    "cpx": "1.5.0",
    "csv-parse": "4.10.1",
    "dd-trace": "0.22.1",
    "deepmerge": "4.2.2",
    "dotenv": "8.2.0",
    "express-jwt": "6.0.0",
    "form-data": "3.0.0",
    "googleapis": "52.1.0",
    "graphql": "15.3.0",
    "graphql-tools": "6.0.12",
    "graphql-type-json": "0.3.2",
    "hot-shots": "7.7.1",
    "inquirer": "7.3.0",
    "is-jpg": "2.0.0",
    "jsforce": "1.9.3",
    "jsonwebtoken": "8.5.1",
    "launchdarkly-node-server-sdk": "5.13.3",
    "lodash": "4.17.19",
    "moment": "2.27.0",
    "mustache": "4.0.1",
    "neo4j-driver": "4.1.0",
    "nest-schedule": "0.6.4",
    "nest-status-monitor": "0.1.3",
    "npm-run-all": "4.1.5",
    "pg": "8.2.1",
    "pushid": "1.0.0",
    "read-chunk": "3.2.0",
    "reflect-metadata": "0.1.13",
    "replace-in-file": "6.1.0",
    "request": "2.88",
    "rosie": "2.0.1",
    "rxjs": "6.6.0",
    "rxjs-compat": "6.6.0",
    "serialize-javascript": ">=4.0.0",
    "sinon": "9.0.2",
    "slonik": "^22.4.11",
    "slonik-interceptor-query-logging": "^1.3.8",
    "striptags": "3.1.1",
    "swagger-ui-express": "4.1.4",
    "trash-cli": "3.0.0",
    "typed-rest-client": "1.7.3",
    "typeorm": "0.2.25",
    "typescript": "3.9.6",
    "unirest": "0.6.0",
    "uuid": "8.2.0",
    "winston": "3.3.3"
  },
  "devDependencies": {
    "@types/body-parser-xml": "^1.1.0",
    "@types/express": "^4.17.6",
    "@types/got": "9.6.11",
    "@types/graphql": "14.5.0",
    "@types/graphql-type-json": "0.3.2",
    "@types/jest": "26.0.3",
    "@types/jsonwebtoken": "8.5.0",
    "@types/sinon": "9.0.4",
    "@types/slonik": "22.1.2",
    "@types/supertest": "2.0.10",
    "@typescript-eslint/eslint-plugin": "^3.8.0",
    "@typescript-eslint/parser": "^3.8.0",
    "audit-ci": "3.1.1",
    "envsub": "4.0.7",
    "eslint": "^7.6.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-import-resolver-webpack": "^0.12.2",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsdoc": "^30.2.0",
    "eslint-plugin-prefer-arrow": "^1.2.2",
    "eslint-plugin-prettier": "^3.1.4",
    "husky": "4.2.5",
    "jest": "26.1.0",
    "jest-junit": "11.0.1",
    "jest-runner-tsc": "1.6.0",
    "lint-staged": "10.2.11",
    "node-mocks-http": "1.8.1",
    "npm-check": "5.9.2",
    "prettier": "^2.0.5",
    "supertest": "4.0.2",
    "ts-jest": "26.1.1",
    "ts-loader": "7.0.5",
    "ts-node": "8.10.2",
    "ts-node-dev": "1.0.0-pre.50",
    "tsconfig-paths": "3.9.0",
    "webpack": "4.43.0",
    "webpack-cli": "3.3.12",
    "webpack-node-externals": "1.7.2"
  },
  "resolutions": {
    "**/**/handlebars": ">=4.5.2",
    "**/**/https-proxy-agent": ">=3.0.0",
    "**/**/dot-prop": ">=5.1.1",
    "**/**/elliptic": ">=6.5.3",
    "acorn": "^7.1.1",
    "braces": ">=2.3.1",
    "mem": ">=4.0.0",
    "serialize-javascript": ">=2.1.1",
    "tree-kill": ">=1.2.2",
    "minimist": ">=1.2.3"
  },
 "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "**/*.{ts,js,md,json}": "prettier --write"
  }
}

SalmaKhater avatar Aug 25 '20 15:08 SalmaKhater

Hello ! Did you find any solution ? I have the exact same problem.

VictorGosse avatar Sep 25 '20 10:09 VictorGosse

Same here! Did found solution?

belfortmaycon avatar Mar 11 '21 17:03 belfortmaycon

No. I asked CodeClimate weeks ago, but without an answer yet.

donni106 avatar Mar 11 '21 18:03 donni106

For those getting this issue, I'm getting the same issue using GitLab CI's code quality jobs (which is just a wrapper around the codeclimate docker image), but noticed that I don't get it if my dependencies are there (i.e. node_modules is present and populated). Obviously this isn't going to fix this issue, but for anyone else who stumbles across this issue, there's your fix. The only cause I can think of is that codeclimate isn't pulling in the correct version required.

gigaSproule avatar May 12 '21 09:05 gigaSproule

For those getting this issue, I'm getting the same issue using GitLab CI's code quality jobs (which is just a wrapper around the codeclimate docker image), but noticed that I don't get it if my dependencies are there (i.e. node_modules is present and populated). Obviously this isn't going to fix this issue, but for anyone else who stumbles across this issue, there's your fix. The only cause I can think of is that codeclimate isn't pulling in the correct version required.

I'm also using Gilab's CI and I solve the erros creating my own .codeclimate.yml file with just what I need enabled after the checks session.

Here is what I did:

plugins:
  duplication:
    enabled: true
    config:
      count_threshold: 3
  eslint:
    enabled: true
    channel: "eslint-7"
  config:
    config: ./.eslintrc.js
    extensions:
      - .ts
      - .tsx
exclude_patterns:
  - "__mocks__/"
  - "**/tests/"
  - "**/__tests__/"
  - "**.test.tsx"
  - "**.test.ts"
  - "README.md"
  - "**.min.css"
  - "**.min.js"
  - "node_modules/"
  - "public/"

belfortmaycon avatar May 12 '21 11:05 belfortmaycon

@belfortmaycon I did have a .codeclimate file, but I didn't have the config file nor the extensions specified, so that could have been better configured, but I still get the same error even with it all configured.

gigaSproule avatar May 13 '21 09:05 gigaSproule

it seems that eslint-7 channel provides eslint-plugin-import version 2.18.2: https://github.com/codeclimate/codeclimate-eslint/blob/channel/eslint-7/yarn.lock#L2330, which means that there is no alphabetize rule: https://github.com/benmosher/eslint-plugin-import/blob/v2.18.2/docs/rules/order.md. this rule was introduced in 2.19.0: https://github.com/benmosher/eslint-plugin-import/blob/v2.19.0/docs/rules/order.md

is there somebody who can update the package version to at least that one?

donni106 avatar Jun 14 '21 17:06 donni106

👀

toFrankie avatar May 09 '23 07:05 toFrankie

I just looked at your configuration and found that the new version of eslint-plugins-import does not depend on the alphabetize configuration item. I suggest you take a look at the sort.md document of eslint-plugins-import in the node_modules folder. It may be caused by a configuration update due to version changes.

The existing configuration items are as follows:

property required type description
pattern x string minimatch pattern for the paths to be in this group (will not be used for builtins or externals)
patternOptions object options for minimatch, default: { nocomment: true }
group x string one of the allowed groups, the pathGroup will be positioned relative to this group
position string defines where around the group the pathGroup will be positioned, can be 'after' or 'before', if not provided pathGroup will be positioned like the group

You can set the options like this:

"import/order": [
  "error",
  {
    "groups": [
      "index",
      "sibling",
      "parent",
      "internal",
      "external",
      "builtin",
      "object",
      "type"
    ]
  }
]

ToruKiyono avatar Sep 24 '23 14:09 ToruKiyono

Thanks ! It really works

weltkind6 avatar Dec 05 '23 07:12 weltkind6