question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose the rules list

See original GitHub issue

The version of ESLint you are using. 3.4.0

The problem you want to solve. Since ESLint adds new rules from time to time and I want to make sure I make a decision about every core rule if I want to enable it or not, I’ve been reading the lib/rules/ contents and fail if any of the rule names is not present in the config. This turned out to be a popular feature so it got extracted into a separate package and then into a more general one. All of them apply the same hack of reading the lib/rules/ contents.

It would be good to have it available in the API and not require hacking into ESLint in such a way.

Your take on the correct solution to problem. I want to have a list of all rule names available via the public API. Perhaps via something like:

const rules= require('eslint').getRulesList();

(not sure if that’s the best place but it doesn’t fit for me to any of the current sub-APIs at http://eslint.org/docs/developer-guide/nodejs-api)

I’d expect the rules to be an array of rule definitions where rule definition is more or less what’s in the meta object exported by the rule (+ its name), e.g.:

{
    name: 'comma-dangle',

    docs: {
        description: "require or disallow trailing commas",
        category: "Stylistic Issues",
        recommended: false
    },

    fixable: "code",

    schema: [
        {
            enum: ["always", "always-multiline", "only-multiline", "never"]
        }
    ]
},

Returning the whole object instead of just rule names would allow to do more analysis for the API, e.g. it’d allow to not require specifying deprecated rules: https://github.com/sarbbottam/eslint-find-rules/issues/172

If you’re afraid the whole meta objects is too much information, at least the following would help a lot:

[
    {
        name: 'comma-dangle',
        deprecated: false,
    },
    {
        name: 'no-native-reassign',
        deprecated: true,
    },
]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mgolcommented, Aug 31, 2016

@vitorbal Yes, that looks good! Somehow I haven’t found this one when I was searching for similar issues. 😄

Should we close this one as a duplicate then?

1reaction
jfmengelscommented, Aug 31, 2016

Sounds like it to me, thanks @vitorbal

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expose
Expose : The act of revealing a card to all players. Only the unrezzed installed cards can be exposed unless otherwise noted. An...
Read more >
`.gitlab-ci.yml` keyword reference - GitLab Docs
List repositories Rake task · Migrate snippets Rake tasks · Object storage · Merge request diffs storage · Static objects external storage.
Read more >
CA1002: Do not expose generic lists (code analysis) - .NET
The following generic collections are designed for inheritance and should be exposed instead of List<T>.
Read more >
Dockerfile reference - Docker Documentation
Environment variables are supported by the following list of instructions in the Dockerfile : ADD; COPY; ENV; EXPOSE; FROM; LABEL; STOPSIGNAL; USER; VOLUME ......
Read more >
Ingress - Kubernetes
An Ingress does not expose arbitrary ports or protocols. ... Most importantly, it contains a list of rules matched against all incoming ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found