Code Monkey home page Code Monkey logo

Comments (14)

ljharb avatar ljharb commented on July 19, 2024 1

@MichaelDeBoey the airbnb config defines every single rule in eslint core, eslint-plugin-import, eslint-plugin-react, and eslint-plugin-jsx-a11y. It's a one-time cost that eslint-find-rules helps keep up to date with minimal incremental effort.

In your case, you could easily define them once in a JS object, and then add that object in two places: the root, off; and overrides, as "error".

from eslint-find-rules.

kentcdodds avatar kentcdodds commented on July 19, 2024 1

Hi @ljharb 👋 It's been a while! Hope you're doing awesome.

Are you opposed to someone adding support for this? Seems like what you're suggesting is more of a workaround than a desirable "feature" 🙃

from eslint-find-rules.

ljharb avatar ljharb commented on July 19, 2024 1

@kentcdodds to be specific, it seems like what you're asking is for --unused to also check for the presence of rules in overrides?

Based on the existence of --include=deprecated, it seems reasonable to allow for providing something like --consider=overrides, but I'd still encourage you to define every rule for every file, to comply with the spirit of the "unused" check.

from eslint-find-rules.

MichaelDeBoey avatar MichaelDeBoey commented on July 19, 2024 1

A new use-case we have on eslint-config-kentcdodds is wanting to enable all Jest related rules only for testing files (as can be seen in kentcdodds/eslint-config-kentcdodds#98).

Enabling all the rules in the root just to make our tests happy isn't the preferred way, so this feature could benefit us a lot.

@leepowelldev Do you have the time to create a PR with working version of this or should we look into it ourselves?

from eslint-find-rules.

darekkay avatar darekkay commented on July 19, 2024 1

My workaround is to define high-level configurations (containing overrides) and move all plugin rules into separate files:

root
  - config-all.js
  - react.js
  - nodejs.js
  - plugins
    - base.js
    - jest.js
    - typescript.js

So while react.js uses overrides to apply typescript rules only to TS(X) files, there's a special config file config-all.js that contains all rules without overrides:

module.exports = {
  extends: [
    "../plugins/base.js",
    "../plugins/jest.js",
    "../plugins/typescript.js",
  ],

  plugins: ["@typescript-eslint"],
};

When checking config-all.js, eslint-find-rules will now check all referenced plugins/rules.

from eslint-find-rules.

ljharb avatar ljharb commented on July 19, 2024

The intention is generally for all rules to be defined for every file; in your case, you could define them all at the root, and only enable them in the overrides?

from eslint-find-rules.

MichaelDeBoey avatar MichaelDeBoey commented on July 19, 2024

@ljharb That would be really cumbersome to duplicate all rules.
1 time for just having it there (disabled) and make eslint-find-rules happy and 1 time to enable them.

For now it's only for @typescript-eslint rules, but this can become more in the future.

Like I said: I'm happy to implement it myself if you could point me in the right direction. 🙂

from eslint-find-rules.

kentcdodds avatar kentcdodds commented on July 19, 2024

That makes sense :) I'd definitely use a --consider=overrides flag and I'm ok with that being an opt-in thing personally :)

from eslint-find-rules.

MichaelDeBoey avatar MichaelDeBoey commented on July 19, 2024

@ljharb Could you point me into the right direction please?
I'd love to work on this.

from eslint-find-rules.

ljharb avatar ljharb commented on July 19, 2024

I'm not entirely sure :-) i'd start with tests tho

from eslint-find-rules.

saiichihashimoto avatar saiichihashimoto commented on July 19, 2024

@MichaelDeBoey did you ever figure this out?

from eslint-find-rules.

MichaelDeBoey avatar MichaelDeBoey commented on July 19, 2024

@saiichihashimoto I never had the time to look into this.
If you want to, be my guest! 🙂

from eslint-find-rules.

leepowelldev avatar leepowelldev commented on July 19, 2024

I spent some time on this today, and have it working - ESLint v7 added better support for merging in override rules when building the config. The downside is it would require v7 as the lowest peer dependency to support as CLIEngine is now deprecated. Also it doesn't seem to pickup any plugins that are defined in an overrides block - not sure if this is expected behaviour of ESLint.

from eslint-find-rules.

MichaelDeBoey avatar MichaelDeBoey commented on July 19, 2024

@darekkay This comes down to the same proposal @ljharb did, which is not really preferred in our use-case.

Thanks for the proposal though! 👊

from eslint-find-rules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.