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

Error: reportUnusedDisableDirectives must be any of "error", "warn", "off", and null #802

Closed
qyurila opened this issue Oct 16, 2022 · 2 comments

Comments

@qyurila
Copy link

qyurila commented Oct 16, 2022

Versions:

  • prettier-eslint version: v15.0.1
  • node version: v16.18.0
  • npm (or yarn) version: pnpm v7.18.4

Have you followed the debugging tips?

Yes

Relevant code or config

.eslintrc

{
	"reportUnusedDisableDirectives": true
}

What I did:

I set reportUnusedDisableDirectives option to true and ran prettier-eslint via prettier-eslint-cli.

What happened:

prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine.
prettier-eslint-cli [ERROR]: There was an error formatting "C:\Dev\Playground\debug-eslint\test.js":
    Error: Invalid Options:
    - 'reportUnusedDisableDirectives' must be any of "error", "warn", "off", and null.
        at processOptions (C:\Dev\Playground\debug-eslint\node_modules\.pnpm\eslint@8.25.0\node_modules\eslint\lib\eslint\eslint.js:282:15)
        at new ESLint (C:\Dev\Playground\debug-eslint\node_modules\.pnpm\eslint@8.25.0\node_modules\eslint\lib\eslint\eslint.js:429:34)
        at getESLint (C:\Dev\Playground\debug-eslint\node_modules\.pnpm\prettier-eslint@15.0.1\node_modules\prettier-eslint\dist\utils.js:386:12)
        at eslintFix (C:\Dev\Playground\debug-eslint\node_modules\.pnpm\prettier-eslint@15.0.1\node_modules\prettier-eslint\dist\index.js:176:41)
        at format (C:\Dev\Playground\debug-eslint\node_modules\.pnpm\prettier-eslint@15.0.1\node_modules\prettier-eslint\dist\index.js:113:10)
        at async C:\Dev\Playground\debug-eslint\node_modules\.pnpm\prettier-eslint-cli@7.1.0_prettier-eslint@15.0.1\node_modules\prettier-eslint-cli\dist\format-files.js:255:26
failure formatting 1 file with prettier-eslint

Reproduction repository:

https://github.com/qyurila/reprod-prettier-eslint

Problem description:

The property reportUnusedDisableDirectives should be boolean. What must be "error", "warn", "off", or null is one of API options which has the identical name.

If reportUnusedDisableDirectives is set to "error", null or something, not only ESLint throws an error but also prettier-eslint does not fix any ESLint rule triggered.

This problem prevents the use of any ESLint config package that contains reportUnusedDisableDirectives (e.g. eslint-config-xo), because no matter what type of value is overwritten to reportUnusedDisableDirectives there are still be a problem that makes it unusable. It's urgent to me because I cannot use vs-code-prettier-eslint for my project until the main repo gets fixed!


Suggested solution:

Separate ESLintOptions.overrideConfig from other ESLintOptions properties

Actually, I made a PR about this issue a while ago (#798), but I came out with a more reasonable solution and I thought there should be a discussion about the implementation so I'm creating this issue.

#696 made some ESLint config options that changed in ESLint v8 to be manually moved inside of overrideConfig to "lessen the upgrade overhead". I don't know if there was reportUnusedDisableDirectives option at that time, but anyway, the patch requires a change now because of this option which has an overlapping name. It seems there is no desirable solution that follows the current method because that will eventually make one of the options not configurable.

Given that, I think it would be good solution that adding new eslintOptions option to format.option and move ESLintOptions to it except ESLintOptions.overrideConfig. That's because eslintConfig was named and documented as it accepts ESLint configs, but no other options (e.g. fix, useEslintrc). So creating another format.options for them makes more sense.

Also, it's notable that the proper documentation would be followed, which is actually good because there are kinds of ESLintOptions supports already despite no clear mention of it in docs.

Another (and I originally PRed - #798) solution would be creating a new property apiOptions for format.options. It requires a bit fewer changes than the above solution, but I don't think it's clearly better. You can see how this implementation would look like if you want.

What do you think about it?

@github-actions
Copy link
Contributor

Stale issue

@Nonemoticoner
Copy link

I've just faced the same problem. This is still an issue. Should be reopened!

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

No branches or pull requests

2 participants