ota-meshi / eslint-plugin-yml

This ESLint plugin provides linting rules for YAML.
https://ota-meshi.github.io/eslint-plugin-yml/
MIT License
121 stars 13 forks source link

flat config does not work as documented #310

Closed danielrentz closed 7 months ago

danielrentz commented 7 months ago

When using config "flat/recommended" (eslint.config.js) in an environment linting .js and .yaml together, the plugin fails:

TypeError: Key "rules": Key "yml/no-empty-document": Could not find plugin "yml".

Root cause seems that the config contains two objects. The first one correctly configures the plugin. However, the second object contains the recommended rules without a "files" property, thus ESLint tries to apply these rules on all JS files.

My current workaround is:

return [
  // ...
  eslintPluginYml.configs["flat/recommended"][0],

  {
    files: ["**/*.yaml", "**/*.yml"],
    rules: {
      ...eslintPluginYml.configs["flat/recommended"][1].rules,
      // ... extra rules
    },
  }
];

See also https://github.com/ota-meshi/eslint-plugin-jsonc/issues/313