import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

import/order named option causes eslint error #3075

Closed jschroeter closed 1 month ago

jschroeter commented 1 month ago

When adding the named option as described in the docs, I get the following error:

Error: .eslintrc.cjs:
        Configuration for rule "import/order" is invalid:
        Value {"alphabetize":{"order":"asc"},"named":true,"distinctGroup":true,"warnOnUnassignedImports":false} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2048:23)
    at eval (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2103:18)
    at ConfigValidator.validateRules (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2100:34)
    at ConfigValidator.validateConfigArray (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2226:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3985:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/home/projects/vitejs-vite-qclkzf/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3791:21)
    at FileEnumerator._iterateFilesRecursive (/home/projects/vitejs-vite-qclkzf/node_modules/eslint/lib/cli-engine/file-enumerator.js:450:49)
    at FileEnumerator.iterateFiles (/home/projects/vitejs-vite-qclkzf/node_modules/eslint/lib/cli-engine/file-enumerator.js:299:49)

Demo: https://stackblitz.com/edit/eslint-import-order?file=.eslintrc.cjs,src%2Fmain.js,package.json&terminal=dev Run: npm run lint

Am I missing something?

I worked around this by using

    "sort-imports": [
      "error",
      {
        ignoreDeclarationSort: true,
      },
    ],

but I'm wondering why I can't use the named option of import/order.

ljharb commented 1 month ago

Because that option isn't released yet. Everywhere on github, you can't look at the docs on the default branch - you need to look at them on the tagged version you're using.

jschroeter commented 1 month ago

That makes sense, totally missed that. Thanks!