Skip to content

Missing type file causing estling.config.ts to fail #188

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

Open
nbouvrette opened this issue Mar 22, 2025 · 0 comments
Open

Missing type file causing estling.config.ts to fail #188

nbouvrette opened this issue Mar 22, 2025 · 0 comments

Comments

@nbouvrette
Copy link

nbouvrette commented Mar 22, 2025

With the recent official support of ESLint TypeScript config (ref), when trying to use eslint-plugin-json-files with this simple config in my eslint.config.ts (flatfile format):

  {
    files: ['**/package.json'],
    plugins: {
      'json-files': jsonFilesPlugin,
    },
    processor: jsonFilesPlugin.processors.json,
    rules: {
      // Requires the `license` field in package.json.
      // @see https://github.com/kellyselden/eslint-plugin-json-files/blob/master/docs/rules/require-license.md
      'json-files/require-license': ['error', 'allow-unlicensed'],
      // Prevents dependency collisions between `dependencies` and `devDependencies` in package.json.
      // @see https://github.com/kellyselden/eslint-plugin-json-files/blob/master/docs/rules/require-unique-dependency-names.md
      'json-files/require-unique-dependency-names': ['error'],
      // Use sort-package-json to keep your keys in a predictable order.
      // @see https://github.com/kellyselden/eslint-plugin-json-files/blob/master/docs/rules/sort-package-json.md
      'json-files/sort-package-json': ['error'],
    },
  },

I'm getting Unsafe assignment of an error typed value errors both when assigning the plugins and the processor as well as a Unsafe member access .processors on an 'error' typed value error on the processor value. I think that both these error are cause by the lack of type file.

I created a tempoary d.ts file to work around this issue but it would be great if this would be part of the original package:

declare module 'eslint-plugin-json-files' {
  import type { Linter, Rule } from 'eslint'

  const plugin: {
    processors: {
      json: Linter.Processor
    }
    configs?: Record<string, Linter.Config>
    rules?: Record<string, Rule.RuleModule>
  }

  export default plugin
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant