Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Invalid configuration for rule "@typescript-eslint/indent" #98

Open
AdrienLemaire opened this issue May 29, 2020 · 16 comments
Open

Invalid configuration for rule "@typescript-eslint/indent" #98

AdrienLemaire opened this issue May 29, 2020 · 16 comments

Comments

@AdrienLemaire
Copy link

AdrienLemaire commented May 29, 2020

Getting an error with this plugin which breaks my vim eslint plugin integration:

[Error  - 1:08:39 PM] .eslintrc.yml » eslint-config-airbnb-typescript » 
/home/dori/Projects/Work/project-v3/client/node_modules/eslint-config-airbnb-typescript/lib/shared.js: 	
Configuration for rule "@typescript-eslint/indent" is invalid: 	
Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoredNodes":["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"ignoreComments":false,"offsetTernaryExpressions":false} 
should NOT have additional properties. 

Using eslint-config-airbnb-typescript 7.2.1

@AdrienLemaire
Copy link
Author

Strangely, not even settings

rules:
  "@typescript-eslint/indent":
    - off
    - 2
    - {}

in my .eslintrc.yml file could fix it. I had to comment l.49 of node_modules/eslint-config-airbnb-typescript/lib/shared.js

    //'@typescript-eslint/indent': baseStyleRules.indent,

@sannysoft
Copy link

Got this error as well.

@iamturns
Copy link
Owner

iamturns commented Jun 3, 2020

Hey @AdrienLemaire and @sannysoft

Sorry, I'm not sure how to replicate this problem. Is it easy to set this up from scratch? Would appreciate any additional details. Cheers!

@hbak
Copy link

hbak commented Jun 9, 2020

I was getting this issue and found that it does not happen when I run npx eslint myfile.ts in the same directory where I have eslint installed, i.e. it's in ./node_modules/eslint

When it's not installed in node_modules, and npx d/ls and runs it from a temporary npx location e.g. /home/user/_npx/... I do get this issue.

Hope this helps

@Zanderinos
Copy link

Same here, while bumping Eslint 6.8.0 to 7.2.0

Using eslint-config-airbnb-typescript 7.2.1 and 8.0.2

@adg29
Copy link

adg29 commented Jun 16, 2020

Same issue, observed after running eslint-config-prettier CLI tool
npx eslint --print-config index.js | npx eslint-config-prettier-check

@iamturns
Copy link
Owner

This might be caused by updating to ESLint v7, which was not supported.

v9.0.0 of this library has just been released, and includes support for ESLint v7. Hopefully this fixes the issue.

@kael89
Copy link

kael89 commented Jul 23, 2020

Still getting this error when using v9.0.0 of this library

@fmendez89
Copy link

Still getting the same issue with version 9.0.0

Error: .eslintrc » eslint-config-airbnb-typescript » ...\node_modules\eslint-config-airbnb-typescript\lib\shared.js:
Configuration for rule "@typescript-eslint/indent" is invalid:
Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoredNodes":["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"ignoreComments":false,"offsetTernaryExpressions":false} should NOT have additional properties.






@mlenser
Copy link

mlenser commented Jul 28, 2020

@iamturns would you be willing to put out a quick version that comments out the @typescript-eslint/indent rule until you have time to do a proper fix? Line 71 below.

image

Else we're in a pretty bad position with options of having to manually comment it out for many developers each time we run yarn, downgrade, or abandon this package.

@elado
Copy link

elado commented Jul 28, 2020

Also experiencing this, and I looks like the root cause is multiple versions of @typescript-eslint/eslint-plugin in the hierarchy of node_modules, and eslint resolving to root node_modules packages that may be in different versions than the expectation.

Like airbnb, I encapsulate configs in a package (say @company/config-eslint), the package has a dep on @typescript-eslint/eslint-plugin@3.7.1, but when this package is installed elsewhere with another dep that has an older version, yarn installs both, and the newer is nested under node_modules/@company/config-eslint/node_modules:

# node_modules

@typescript-eslint/eslint-plugin@2.34.0 <-- too old
@typescript-eslint/parser@3.7.1
@company/config-eslint/node_modules/@typescript-eslint/eslint-plugin@3.7.1 <-- the new one is nested

when eslint resolves the plugins by name, it uses the one at the root of node_modules, which is 2.34.0, and the error shows.

In a different repo without the additional older version as a sub dep of one of the deps, v9.0.0 works without the indent config error.

This can possibly be resolved by using full paths (require.resolve) in the eslint config, instead of plugin names. A support for this is coming to eslint. See: eslint/rfcs#14 / eslint/rfcs#9

I was able to solve it, quite hackishly, using yarn resolutions, in the root package.json of the repo.

  "resolutions": {
    "@typescript-eslint/eslint-plugin": "^3.7.1"
  }

and this will also work if I add it as a local dependency.

EDIT: I hit this again in a different project, and the solution was to install eslint at the root.

@nstrelow
Copy link

Still having this using globally installed eslint with typescript-eslint and airbnb-typescript:

  • eslint: 7.9.0
  • @typescript-eslint/eslint-plugin: 4.1.1
  • eslint-config-airbnb-typescript: 10.0.0
Error: .eslintrc.json » eslint-config-airbnb-typescript » xxxxxx/node_modules/eslint-config-airbnb-typescript/lib/shared.js:
	Configuration for rule "@typescript-eslint/indent" is invalid:
	Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoredNodes":["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"ignoreComments":false,"offsetTernaryExpressions":false} should NOT have additional properties.

@ed-sparkes
Copy link

Still having this using globally installed eslint with typescript-eslint and airbnb-typescript:

  • eslint: 7.17.0
  • @typescript-eslint/eslint-plugin: 4.9.0
  • eslint-config-airbnb-typescript: 12.0.0

Also for reference using yarn 2

Does anyone have any clue how to solve it, thanks

@HassanNiazi
Copy link

HassanNiazi commented Feb 15, 2021

For a temporary fix to this problem use the following package versions.

  • eslint-config-airbnb-typescript: "^12.3.1"
  • eslint-plugin-import: "^2.22.1"
  • eslint: "^7.19.0"
  • @typescript-eslint/eslint-plugin: "^4.15.0"

@ishabo
Copy link

ishabo commented Apr 12, 2021

I tried multiple versions. The latest for all those libraries to this day, as well as some of the suggested combinations.
What's weird is that it works fine when I add those packages to the project I am linting, but when I separate the eslint config to be a standalone yarn workspace I get the same issue with type "@typescript-eslint/indent" and commenting //@typescript-eslint/indent': baseStyleRules.indent, removes that issue.

@earloc
Copy link

earloc commented Dec 29, 2022

just faced the same issue (one and a half year later) on a project I have to maintain, running on a linux-based (ubuntu-latest) vsts-worker, using lerna, when I initially enabled eslint with latest packages:

Error: .eslintrc.js » eslint-config-airbnb-typescript/base » /home/vsts/work/1/s/packages/util-health-check/node_modules/eslint-config-airbnb-typescript/lib/shared.js:
	Configuration for rule "@typescript-eslint/indent" is invalid:
	Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoredNodes":["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"ignoreComments":false,"offsetTernaryExpressions":false} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (/home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2027:23)
    at /home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2082:18
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateRules (/home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2079:34)
    at ConfigValidator.validateConfigArray (/home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2205:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (/home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3962:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/home/vsts/work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3768:21)
    at FileEnumerator._iterateFilesRecursive (/home/vsts/work/1/s/packages/util-health-check/node_modules/eslint/lib/cli-engine/file-enumerator.js:448:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/home/vsts/work/1/s/packages/util-health-check/node_modules/eslint/lib/cli-engine/file-enumerator.js:299:49)

package.json:

...
"scripts": {
    "build": "tsc",
    "test": "jest --coverage",
    "test:watch": "jest --watch",
    "lint": "npx eslint src --ext .ts",
    "lint:fix": "npx eslint src --ext .ts --fix"
  },
  "devDependencies": {
    "@types/jest": "^29.2.4",
    "@types/node": "^18.11.18",
    "@typescript-eslint/eslint-plugin": "^5.47.1",
    "@typescript-eslint/parser": "^5.47.1",
    "eslint": "^8.30.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-airbnb-typescript": "^17.0.0",
    "eslint-plugin-import": "^2.22.1",
    "jest": "^29.3.1",
    "jest-junit": "^15.0.0",
    "ts-jest": "^29.0.3",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.4"
  }
...

.eslintrc.js

module.exports = {
    "env": {
        "browser": false,
        "node": true
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "tsconfig.json",
        "sourceType": "module"
    },
    "extends": [
        'airbnb-base',
        'airbnb-typescript/base'
    ],
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
        "max-len": ["error", { "code": 250 }]
    },
    "ignorePatterns": [
        ".eslintrc.js"
    ]
};

When running the same command on WSL2 for Windows, everything works as expected, though.

Am I missing sth?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests