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

I tried adding this rule to my .eslint.js #14

Open
morgan-zylotech opened this issue Dec 1, 2020 · 1 comment
Open

I tried adding this rule to my .eslint.js #14

morgan-zylotech opened this issue Dec 1, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@morgan-zylotech
Copy link

morgan-zylotech commented Dec 1, 2020

I've imported this ruleset into my application in my package.json file

"eslint-plugin-react-security": "git+ssh://[email protected]:snyk-labs/eslint-plugin-react-security.git",

I've declared the rule in my .eslintrc.js file like:

  plugins: [
    'react',
    'cypress',
    'html',
    'no-unsanitized',
    'react-security',
    'security',
  ],
  rules: {
    // # https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
    'react/no-danger': 'warn',
    'react/no-find-dom-node': 'warn',
    'react/jsx-no-script-url': 'warn',
    'react/jsx-no-target-blank': 'warn',
    'react/jsx-props-no-spreading': 'warn',
    // https://github.com/snyk-labs/eslint-plugin-react-security
    'no-refs': 'warn',
   // https://github.com/mozilla/eslint-plugin-no-unsanitized
    'no-unsanitized/method': 'error',
    'no-unsanitized/property': 'error',
}

as per the file - https://github.com/snyk-labs/eslint-config-react-security/blob/master/index.js

Which leads me to this error when running eslint in the application directory.

1:1 error Definition for rule 'no-refs' was not found

Only when I

change 'no-refs': 'warn', to 'react-security/no-refs': 'warn', does the error go away and the rule properly resolve.

I think this could easily be solved with some documentation.

The reason my this might get some attention is that someone at Synk blogged about it recently - https://snyk.io/blog/10-react-security-best-practices/

@lirantal
Copy link
Member

lirantal commented Dec 5, 2020

@morgan-zylotech thanks for coming by and proposing the solution here.
Would you like to send over the Pull Request with the fix?

@lirantal lirantal added the bug Something isn't working label Dec 5, 2020
@lirantal lirantal self-assigned this Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants