-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Hello folks,
This plugin is looking in great shape lately, so I decided to try it out in my sharable linting config. However, I found a "gotcha" that I did not expect.
To start with, I am turning on on the plugin like this:
export const basePackageJSON = defineConfig({
plugins: {
// @ts-expect-error https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/1242
"package-json": ESLintPluginPackageJSON,
},
files: ["**/package.json"],
languageOptions: {
parser: parserJsonc,
parserOptions: {
extraFileExtensions: [".json"],
},
},
rules: {
// [snip]
},
});I have found that because of the files line, OTHER ESLint rules will now automatically apply to "package.json" files, which causes errors like this:
Error: Error while loading rule 'isaacscript/no-invalid-default-map': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://typescript-eslint.io/getting-started/typed-linting for enabling linting with type information.
Parser: typescript-eslint/parser
Occurred while linting D:\Repositories\isaacscript\packages\isaac-lua-polyfill\package.json
To get around this, I put a ignores: ["**/*.json"] in the blocks where I turn on rules with type information. But the problem with this is that it is not "sharable". What I mean is that, in my sharable ESLint config, if any downstream user extends it and then turns on a rule with type information "on top", then THEY will have to also know about this foot-gun and remember to add on their own copy of ignores: ["**/*.json"]. Yuck!
So, my question is: Is there a trick to enable this plugin but do it in a way that doesn't cause commotion with other ESLint rules?