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

Bug: reportUnusedDisableDirectives with value warn is not respected by the cli #16002

Closed
1 task done
smac89 opened this issue Jun 14, 2022 · 1 comment
Closed
1 task done
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion works as intended The behavior described in this issue is working correctly
Projects

Comments

@smac89
Copy link

smac89 commented Jun 14, 2022

Environment

Node version: v16.15.1
npm version: v8.11.0
Local ESLint version: v8.17.0 (Currently used)
Global ESLint version: Not found
Operating System: linux 5.18.1-arch1-1

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration
env:
  es2021: true
  node: true
extends:
  - '../node_modules/gts/'
parserOptions:
  ecmaFeatures:
    jsx: true
  sourceType: module
plugins:
  - react
  - '@typescript-eslint'
settings:
    react:
        version: 'detect'
    typescript:
        alwaysTryTypes: true
reportUnusedDisableDirectives: 'warn'
overrides:
  - files: ['craco.config.ts']
    rules:
      'node/no-unpublished-import': 0

What did you expect to happen?

When linting using the cli, it always complains that reportUnusedDisableDirectives should be a boolean rather than 'warn', but the newest version of eslint already supports using 'warn' as an option to reportUnusedDisableDirectives.

What actually happened?

I get an error:

Oops! Something went wrong! :(

ESLint: 8.17.0

Error: ESLint configuration in .eslintrc.yaml is invalid:
        - Property "reportUnusedDisableDirectives" is the wrong type (expected boolean but got `"warn"`).

    at ConfigValidator.validateConfigSchema (/home/chigozirim/Dev/vpn-client/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:19)
    at ConfigArrayFactory._normalizeConfigData (/home/chigozirim/Dev/vpn-client/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2982:19)
    at ConfigArrayFactory.loadInDirectory (/home/chigozirim/Dev/vpn-client/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2850:33)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/home/chigozirim/Dev/vpn-client/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3833:46)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/home/chigozirim/Dev/vpn-client/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3754:18)
    at FileEnumerator._iterateFilesRecursive (/home/chigozirim/Dev/vpn-client/node_modules/eslint/lib/cli-engine/file-enumerator.js:446:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/home/chigozirim/Dev/vpn-client/node_modules/eslint/lib/cli-engine/file-enumerator.js:297:49)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (/home/chigozirim/Dev/vpn-client/node_modules/eslint/lib/cli-engine/cli-engine.js:786:48)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 2
Command: /home/chigozirim/.local/share/zinit/plugins/lukechilds---zsh-nvm/nvm/versions/node/v16.15.1/bin/node
Arguments: /home/chigozirim/.node/corepack/yarn/1.22.15/lib/cli.js lint --debug
Directory: /home/chigozirim/Dev/vpn-client/www
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

This bug was kinda weird because it doesn't occur when I use prettier-eslint to format the files, only when I use eslint cli does it occur. They both use the new ESLint class, but somewhere in the code, the cli is still using the old format for the configs...

I tried tracing the problem, and I think it may have to do with the use of the legacy eslintrc module:

const {
Legacy: {
IgnorePattern,
CascadingConfigArrayFactory
}
} = require("@eslint/eslintrc");

And here is where the config is validated...again

https://github.com/eslint/eslintrc/blob/a57d60877c12601a7f012710a0be2bda8088a947/lib/shared/config-validator.js#L268-L273

And this is the offending config:
https://github.com/eslint/eslintrc/blob/a57d60877c12601a7f012710a0be2bda8088a947/conf/config-schema.js#L23

@smac89 smac89 added bug ESLint is working incorrectly repro:needed labels Jun 14, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Jun 14, 2022
@mdjermanovic mdjermanovic moved this from Needs Triage to Triaging in Triage Jun 14, 2022
@mdjermanovic mdjermanovic added works as intended The behavior described in this issue is working correctly and removed bug ESLint is working incorrectly repro:needed labels Jun 14, 2022
@mdjermanovic
Copy link
Member

Hi @smac89, thanks for the issue!

This works as intended. In configuration files and configuration objects (like baseConfig and overrideConfig in the API), allowed values for reportUnusedDisableDirectives are only true and false.

API options are not necessarily the same as config options.

There is a proposal to allow specifying severity in config files (#15466 (comment)) but at the moment only boolean values are allowed, where false maps to "off" and true maps to "warn".

@mdjermanovic mdjermanovic closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2022
Triage automation moved this from Triaging to Complete Jun 14, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Dec 12, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion works as intended The behavior described in this issue is working correctly
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

2 participants