eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

`multipleFileExtensions` in `unicorn/filename-case` is not working correctly with eslint flat config

Open Geloosa opened this issue 10 months ago • 0 comments

eslint 8.57.0 eslint-plugin-unicorn 51.0.1 rule unicorn/filename-case

When using a flat config, multipleFileExtensions option is not true by default and can't be set to true.

This config

{
  files: [
      "**/*.stories.js",
      "**/*.stories.ts",
      "**/*.view.test.js",
      "**/*.view.test.ts",
    ],
  rules: {
      "unicorn/filename-case": [
        "error",
        { case: "pascalCase" },
      ],
    },
}

outputs this error (though it should't)

/MobileMenu.stories.js
  1:1  error  Filename is not in pascal case. Rename it to `MobileMenu.Stories.js`  unicorn/filename-case

When trying to set multipleFileExtensions to true explicitly:

{
  files: [
      "**/*.stories.js",
      "**/*.stories.ts",
      "**/*.view.test.js",
      "**/*.view.test.ts",
    ],
  rules: {
      "unicorn/filename-case": [
        "error",
        { case: "pascalCase", multipleFileExtensions: true },
      ],
    },
}

eslint doesn't run throwing a config validation error:

Oops! Something went wrong! :(

Error: Key "rules": Key "unicorn/filename-case":        Value {"case":"pascalCase","multipleFileExtensions":true} should NOT have additional properties.
        Value {"case":"pascalCase","multipleFileExtensions":true} should NOT have additional properties.
        Value {"case":"pascalCase","multipleFileExtensions":true} should match exactly one schema in oneOf.

Geloosa avatar Apr 03 '24 13:04 Geloosa