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 recommended rules to plugin config? #9

Closed
pdehaan opened this issue Feb 9, 2017 · 3 comments
Closed

Add recommended rules to plugin config? #9

pdehaan opened this issue Feb 9, 2017 · 3 comments

Comments

@pdehaan
Copy link
Contributor

pdehaan commented Feb 9, 2017

It may be super-neat if there was a recommended config bundled in the plugin (Ref: eslint-plugin-react).

This would let us do something like:

{
  "extends": [
    "eslint:recommended",
    "plugin:security/recommended"
  ],
  "plugins": [
    "security"
  ]
}

I think it's as easy as adding a configs.recommended.rules object to the index.js:

/**
 * eslint-plugin-security - ESLint plugin for Node Security
 */

'use strict';

module.exports = {
  rules: {
    // ...
  },
  rulesConfig: {
    // ...
  },
  configs: {
    recommended: {
      rules: {
        'security/detect-buffer-noassert': 'warn',
        'security/detect-child-process': 'warn',
        'security/detect-disable-mustache-escape': 'warn',
        'security/detect-eval-with-expression': 'warn',
        'security/detect-new-buffer': 'warn',
        'security/detect-no-csrf-before-method-override': 'warn',
        'security/detect-non-literal-fs-filename': 'warn',
        'security/detect-non-literal-regexp': 'warn',
        'security/detect-non-literal-require': 'warn',
        'security/detect-object-injection': 'warn',
        'security/detect-possible-timing-attacks': 'warn',
        'security/detect-pseudoRandomBytes': 'warn',
        'security/detect-unsafe-regex': 'warn'
      }
    }
  }
};

Individual rules can overridden in the user's .eslintrc file:

{
  "extends": [
    "eslint:recommended",
    "plugin:security/recommended"
  ],
  "plugins": [
    "security"
  ],
  "rules": {
    "security/detect-object-injection": "off"
  }
}
@travi
Copy link
Contributor

travi commented Apr 5, 2017

is this something that the team is open to? recommended rulesets do greatly simplify plugin inclusion. would you accept a PR with a recommended set that enabled all rules as errors?

@jlamendo
Copy link
Contributor

jlamendo commented Apr 6, 2017

I believe this was resolved with #10

@jlamendo jlamendo closed this as completed Apr 6, 2017
@travi
Copy link
Contributor

travi commented Apr 6, 2017

ah, nice. would be great if it were mentioned in the usage section of the readme.

travi added a commit to travi/eslint-plugin-security that referenced this issue Apr 7, 2017
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

No branches or pull requests

3 participants