Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dot-notation] [Bug] Configuration for rule "dot-notation" is invalid #2047

Closed
mubaidr opened this issue May 19, 2020 · 4 comments
Closed

[dot-notation] [Bug] Configuration for rule "dot-notation" is invalid #2047

mubaidr opened this issue May 19, 2020 · 4 comments
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended

Comments

@mubaidr
Copy link

mubaidr commented May 19, 2020

When using rules: eslint-config-standard-with-typescript

Configuration for rule "dot-notation" is invalid:
        Value {"allowKeywords":true,"allowPattern":"","allowPrivateClassPropertyAccess":false} should NOT have additional properties.

Repro

Repository:
Just update the version and try: https://github.com/BrainJS/brain.js/tree/git-hooks
OR

{
  "env": {
    "es6": true
  },
  "extends": [
    "eslint:recommended",
    "standard-with-typescript",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 11,
    "project": "./tsconfig.json",
    "sourceType": "module"
  },
  "plugins": ["prettier", "@typescript-eslint"],
  "root": true,
  "rules": {
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/interface-name-prefix": "off",
    "@typescript-eslint/member-delimiter-style": "off",
    "@typescript-eslint/no-empty-function": "off",
    "@typescript-eslint/no-var-requires": "off",
    "@typescript-eslint/semi": "off",
    "@typescript-eslint/space-before-function-paren": "off",
    "arrow-parens": "off",
    "class-methods-use-this": "off",
    "max-classes-per-file": "off",
    "no-continue": "off",
    "no-empty-function": "off",
    "no-multi-assign": "off",
    "no-param-reassign": "off",
    "no-plusplus": "off",
    "no-prototype-builtins": "off",
    "no-restricted-globals": "off",
    "no-underscore-dangle": "off",
    "prettier/prettier": "error",
    "semi": "off",
    "standard/no-callback-literal": "off"
  }
}

Expected Result
Should lint files.

Actual Result

Eslint fails.

Additional Info
This happens when using rules eslint-config-standard-with-typescript. more info: mightyiam/eslint-config-love#303

Did eslint throw an exception? Yes

Oops! Something went wrong! :(

ESLint: 7.0.0

Error: .eslintrc.json » eslint-config-standard-with-typescript » eslint-config-standard:
        Configuration for rule "dot-notation" is invalid:
        Value {"allowKeywords":true,"allowPattern":"","allowPrivateClassPropertyAccess":false} should NOT have additional properties.

    at validateRuleOptions (D:\current\brain.js\node_modules\eslint\lib\shared\config-validator.js:132:19)
    at D:\current\brain.js\node_modules\eslint\lib\shared\config-validator.js:187:9
    at Array.forEach (<anonymous>)
    at validateRules (D:\current\brain.js\node_modules\eslint\lib\shared\config-validator.js:184:30)
    at validateConfigArray (D:\current\brain.js\node_modules\eslint\lib\shared\config-validator.js:312:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (D:\current\brain.js\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:464:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (D:\current\brain.js\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:275:21)
    at FileEnumerator._iterateFilesRecursive (D:\current\brain.js\node_modules\eslint\lib\cli-engine\file-enumerator.js:467:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (D:\current\brain.js\node_modules\eslint\lib\cli-engine\file-enumerator.js:287:49)

Versions

package version
@typescript-eslint/eslint-plugin 2.34.0
@typescript-eslint/parser 2.34.0
TypeScript 3.9.2
ESLint ^7.0.0
node 12.16.0
npm 6.14.4
@mubaidr mubaidr added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels May 19, 2020
@bradzacher
Copy link
Member

You're not using our version of the lint rule - you're using the base version of the lint rule.
Use @typescript-eslint/dot-notation

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for maintainers to take a look labels May 19, 2020
@LinusU
Copy link
Contributor

LinusU commented May 20, 2020

@bradzacher actually, we are using the @typescript-eslint/dot-notation rule. I think that the problem lies here:

import baseRule from 'eslint/lib/rules/dot-notation';

const rules = baseRule.create(context);

https://github.com/eslint/eslint/blob/c636d5708c461a8ff1ea55e5df56d4f76f9c4044/lib/rules/dot-notation.js#L60

Basically, all options gets passed to the base rule, which then complains about the extra options 🤔

@bradzacher
Copy link
Member

It's not baseRule.create that does the schema checking - eslint does that whilst it's setting up the context object.

the create function is a direct call into the rule's code (i.e. into the code you linked).

This is not a problem with our implementation, because if it were then all of our tests would be failing.

The error message says it all:

Configuration for rule "dot-notation" is invalid

That means that ESLint is attempting to enable the dot-notation rule with the options you're providing.

If you use eslint --print-config <filename>, eslint will resolve the config for the specified file, and dump it out, which will likely show the dot-notation rule being turned on.

@LinusU
Copy link
Contributor

LinusU commented May 20, 2020

Thank you for the quick response, I will do some further investigation!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

3 participants