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

Proposal: Provide a defineConfig function #14249

Closed
Shinigami92 opened this issue Mar 24, 2021 · 2 comments
Closed

Proposal: Provide a defineConfig function #14249

Shinigami92 opened this issue Mar 24, 2021 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon
Projects

Comments

@Shinigami92
Copy link
Contributor

Shinigami92 commented Mar 24, 2021

The version of ESLint you are using.
<= 7.22.0

The problem you want to solve.

When building up a .eslintrc.js I do not get provided inline help, autosuggestion, documentation or type-safety.
Also if a new major breaking change is introduced by eslint, I do not see directly if my config is still working or not by opening the file and trust the compiler.

Your take on the correct solution to problem.

Vite idea to the rescue 🚑

Provide a defineConfig function that can be require/import-ed in the configuration file. It is a bit like json-schema.

The defineConfig function itself does nothing at runtime, it's just

export function defineConfig(config: EslintConfig) {
  return config;
}

TypeScript Playground Example

Are you willing to submit a pull request to implement this change?

I think so, but someone needs to help me to find where and how I should add the functionality and TypeScript definitions.

Alternative approach

Provide a new package like eslint-define-config

@Shinigami92 Shinigami92 added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels Mar 24, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Mar 24, 2021
@Shinigami92
Copy link
Contributor Author

I already jumped ahead and published npm version 😄

Repo: https://github.com/Shinigami92/eslint-define-config

Anyone who wants to help is welcome, I accept PRs now!

@nzakas
Copy link
Member

nzakas commented Mar 25, 2021

It sounds like what you’re asking for is for ESLint to ship type definitions for config files?

We are in the middle of transitioning to a new config system (see #13481) so we aren’t making any further changes to the existing config system.

We also haven’t shipped type definitions for anything before, and I’m not sure that’s a direction we want to go in.

Given that you’ve already implemented a package that does what you want, it seems like using that package is the best option.

@nzakas nzakas closed this as completed Mar 25, 2021
Triage automation moved this from Needs Triage to Complete Mar 25, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Sep 22, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon
Projects
Archived in project
Triage
Complete
Development

No branches or pull requests

2 participants