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

Add all config to automatically load all rules at error level #22

Open
victornpb opened this issue Oct 18, 2023 · 5 comments · May be fixed by #23
Open

Add all config to automatically load all rules at error level #22

victornpb opened this issue Oct 18, 2023 · 5 comments · May be fixed by #23

Comments

@victornpb
Copy link

I tried this, but none of them work

module.exports = {
  root: true,
  env: {
    node: true
  },
  plugins: ['eslint-plugin-local-rules'],
  extends: [
    'eslint:recommended',
    'plugin:vue/essential',
    'plugin:eslint-plugin-local-rules', // nope
    'plugin:eslint-plugin-local-rules:recommended',  // nope
    'plugin:eslint-plugin-local-rules/recommended', // nope
  ],
...

rule example

module.exports = {
    meta: {
      docs: {
        description: 'disallow identifiers',
        category: 'Possible Errors',
        recommended: true,
      },
      schema: [],
    },
    create: function (context) {
      return {
        Identifier: function (node) {
          context.report({
            node: node,
            message: 'Identifiers not allowed for Super Important reasons.',
          });
        },
      };
    },
};
@cletusw
Copy link
Owner

cletusw commented Nov 25, 2023

Looks like the automatic inclusion of recommended: true rules only applies to core rules: https://eslint.org/docs/latest/extend/custom-rules#rule-structure:~:text=The%20following%20properties%20are%20only%20relevant%20when%20working%20on%20core%20rules

I'll remove that line from the README snippet, but to accomplish this you'd need to do what other non-core plugins have to do (example) and define your own "recommended" config following https://eslint.org/docs/latest/extend/plugins#configs-in-plugins .

This plugin currently doesn't allow that, but I believe https://github.com/taskworld/eslint-plugin-local can do what you need. I'll close this issue, but feel free to +1 #11 and we can maybe revive that.

As an aside, you may have it in a separate file, but just in case, make sure your actual eslint-local-rules.js file includes the rule identifiers as keys:

module.exports = {
  'disallow-identifiers': {
    meta: {

instead of just

module.exports = {
    meta: {

@cletusw cletusw closed this as completed Nov 25, 2023
@fregante
Copy link
Contributor

fregante commented Nov 25, 2023

I think the point of this request is to include a recommended.js file in this package so that it automatically picks up any available rules and enables them. Essentially "configs in plugins", but as part of eslint-plugin-local-rules (which is the plugin here)

The file technically should be all.js rather than recommended.js, because recommended implies that some rules are not enabled by the config.

#11 is something different and unnecessary here. eslint-plugin-local-rules is useful to load local rules, not move the location of the config; that config should just be added to .eslintrc

@cletusw
Copy link
Owner

cletusw commented Nov 25, 2023

Great suggestion! Reopening & renaming to be a request for a bundled all config.

@cletusw cletusw reopened this Nov 25, 2023
@cletusw cletusw changed the title How to enable all recommended rules by default Add all config to automatically load all rules at error level Nov 25, 2023
@fregante
Copy link
Contributor

I'll send a tentative PR

@cletusw
Copy link
Owner

cletusw commented Nov 25, 2023

Excellent, thanks!

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

Successfully merging a pull request may close this issue.

3 participants