Skip to content
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

provide type support for .eslintrc.js #2488

Closed
tadhgmister opened this issue Sep 4, 2020 · 1 comment
Closed

provide type support for .eslintrc.js #2488

tadhgmister opened this issue Sep 4, 2020 · 1 comment
Labels
package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look

Comments

@tadhgmister
Copy link
Contributor

I really appreciate my IDE's suggestions and intellisense, and it always bugged me that the eslintrc had no support.

Today I found that the basic structure of the eslintrc format is present in Linter.ts so today I added this to my .eslintrc.js for my personal repo:

// @ts-check
/** @type {import("@typescript-eslint/experimental-utils/dist/ts-eslint/Linter").Linter.Config} */
const config = {
     ...
};
module.exports = config;

This internal type doesn't contain any rule information but I think an official version of this would be desirable:

  • it could be generated with a similar script to generate-configs.ts
  • both type check, and give auto-complete for specifying options
  • can make configuration for base rules that don't work so users get errors like this:

no-shadow error with doc-string telling them to use the correct rule

(code that produces above message)

As well with namespace merging it should be possible to provide an easy way for other packages to define a .d.ts file to define their own rule options, something like this would be useful:

declare namespace ESLINT {
    type Severity = 0 | 1 | 2 | "off" | "warn" | "error";
    type RuleOption<Settings extends unknown[] = []> = Severity | [Severity, ...Settings];
    interface Rules extends Record<string, RuleOption<unknown[]>> {
        "no-shadow": "off";
        "@typescript-eslint/no-shadow": RuleOption<[]>;
    }
}
// in another library:
declare namespace ESLINT {
    interface Rules {
        "import/first": RuleOption; // specific options specified
    }
}

I think there might be a way to allow this without polluting the global namespace but it'd require some investigation.

In any case I do think this is worth some consideration and I am more than happy to implement It.

@tadhgmister tadhgmister added package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look labels Sep 4, 2020
@tadhgmister
Copy link
Contributor Author

never mind, duplicate of #1296,

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look
Projects
None yet
Development

No branches or pull requests

1 participant