@thebestco/eslint-config
Advanced tools
Comparing version 2.0.5 to 2.0.6
{ | ||
"name": "@thebestco/eslint-config", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "The BestCompany's shared eslint config", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,3 +49,3 @@ # BestPrice's eslint-config | ||
1. `npm install --save-dev @thebestco/eslint-config eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks@next babel-eslint eslint` | ||
1. `npm install --save-dev @thebestco/eslint-config eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks@next eslint-plugin-react-refresh babel-eslint eslint` | ||
2. add `"extends": "@thebestco/eslint-config/prettier"` to your .eslintrc | ||
@@ -62,2 +62,3 @@ | ||
npm install -g eslint-plugin-react-hooks@next | ||
npm install -g eslint-plugin-react-refresh | ||
npm install -g @thebestco/eslint-config | ||
@@ -64,0 +65,0 @@ ``` |
@@ -6,150 +6,160 @@ var OFF = 0; | ||
module.exports = { | ||
'plugins': [ | ||
'jsx-a11y', | ||
'react', | ||
'react-hooks', | ||
], | ||
plugins: ["jsx-a11y", "react", "react-hooks", "react-refresh"], | ||
// View link below for react rules documentation | ||
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules | ||
'rules': { | ||
rules: { | ||
// Enforce emojis are wrapped in and provide screenreader access. | ||
'jsx-a11y/accessible-emoji': 2, | ||
"jsx-a11y/accessible-emoji": 2, | ||
// Enforce that anchors have content and that the content is accessible to screen readers. | ||
'jsx-a11y/anchor-has-content': 2, | ||
"jsx-a11y/anchor-has-content": 2, | ||
// Enforce all anchors are valid, navigable elements. | ||
'jsx-a11y/anchor-is-valid': 2, | ||
"jsx-a11y/anchor-is-valid": 2, | ||
// Enforce elements with aria-activedescendant are tabbable. | ||
'jsx-a11y/aria-activedescendant-has-tabindex': 2, | ||
"jsx-a11y/aria-activedescendant-has-tabindex": 2, | ||
// Enforce ARIA state and property values are valid. | ||
'jsx-a11y/aria-proptypes': 2, | ||
"jsx-a11y/aria-proptypes": 2, | ||
// Prevent use of `accessKey` | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md | ||
'jsx-a11y/no-access-key': 2, | ||
"jsx-a11y/no-access-key": 2, | ||
// Require <img> to have a non-empty `alt` prop, or role="presentation" | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-uses-alt.md | ||
'jsx-a11y/alt-text': 2, | ||
"jsx-a11y/alt-text": 2, | ||
// Enforce usage of onBlur over onChange on select menus for accessibility. | ||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md | ||
'jsx-a11y/no-onchange': 0, | ||
"jsx-a11y/no-onchange": 0, | ||
'jsx-a11y/img-redundant-alt': 2, | ||
"jsx-a11y/img-redundant-alt": 2, | ||
//:Enforce all aria-* props are valid. | ||
'jsx-a11y/aria-props': 1, | ||
"jsx-a11y/aria-props": 1, | ||
// Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role. | ||
'jsx-a11y/aria-role': 1, | ||
"jsx-a11y/aria-role": 1, | ||
// Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | ||
'jsx-a11y/aria-unsupported-elements': 1, | ||
"jsx-a11y/aria-unsupported-elements": 1, | ||
// Enforce a clickable non-interactive element has at least one keyboard event listener. | ||
'jsx-a11y/click-events-have-key-events': 0, | ||
"jsx-a11y/click-events-have-key-events": 0, | ||
// Enforce heading (h1, h2, etc) elements contain accessible content. | ||
'jsx-a11y/heading-has-content': 1, | ||
"jsx-a11y/heading-has-content": 1, | ||
// Enforce <html> element has lang prop. | ||
'jsx-a11y/html-has-lang': 1, | ||
"jsx-a11y/html-has-lang": 1, | ||
// Enforce iframe elements have a title attribute. | ||
'jsx-a11y/iframe-has-title': 1, | ||
"jsx-a11y/iframe-has-title": 1, | ||
// Enforce lang attribute has a valid value. | ||
'jsx-a11y/lang': 1, | ||
"jsx-a11y/lang": 1, | ||
// Prevent missing displayName in a React component definition | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md | ||
'react/display-name': [0, { 'ignoreTranspilerName': false }], | ||
"react/display-name": [0, { ignoreTranspilerName: false }], | ||
// Forbid certain propTypes (any, array, object) | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md | ||
'react/forbid-prop-types': [1, { 'forbid': ['any'] }], | ||
"react/forbid-prop-types": [1, { forbid: ["any"] }], | ||
// Forbid certain props on DOM Nodes | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md | ||
'react/forbid-dom-props': ['off', { forbid: [] }], | ||
"react/forbid-dom-props": ["off", { forbid: [] }], | ||
// Validate closing tag location in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md | ||
'react/jsx-closing-tag-location': 0, | ||
"react/jsx-closing-tag-location": 0, | ||
// Enforce boolean attributes notation in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md | ||
'react/jsx-boolean-value': [1, 'never'], | ||
"react/jsx-boolean-value": [1, "never"], | ||
// Validate closing bracket location in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md | ||
'react/jsx-closing-bracket-location': [1, { nonEmpty: 'after-props', selfClosing: 'after-props'} ], | ||
"react/jsx-closing-bracket-location": [ | ||
1, | ||
{ nonEmpty: "after-props", selfClosing: "after-props" }, | ||
], | ||
// Enforce or disallow spaces inside of curly braces in JSX attributes | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md | ||
'react/jsx-curly-spacing': [1, 'never', { 'allowMultiline': true }], | ||
"react/jsx-curly-spacing": [1, "never", { allowMultiline: true }], | ||
// Enforce event handler naming conventions in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md | ||
'react/jsx-handler-names': [0, { | ||
'eventHandlerPrefix': 'handle', | ||
'eventHandlerPropPrefix': 'on', | ||
}], | ||
"react/jsx-handler-names": [ | ||
0, | ||
{ | ||
eventHandlerPrefix: "handle", | ||
eventHandlerPropPrefix: "on", | ||
}, | ||
], | ||
// Validate props indentation in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md | ||
'react/jsx-indent-props': [1, 2], | ||
"react/jsx-indent-props": [1, 2], | ||
// Validate JSX has key prop when in array or iterator | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md | ||
'react/jsx-key': 1, | ||
"react/jsx-key": 1, | ||
// Limit maximum of props on a single line in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md | ||
'react/jsx-max-props-per-line': [1, { 'maximum': 2 }], | ||
"react/jsx-max-props-per-line": [1, { maximum: 2 }], | ||
// Prevent usage of .bind() and arrow functions in JSX props | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md | ||
// TODO: set it to allowBind = false | ||
'react/jsx-no-bind': [1, { | ||
'ignoreRefs': true, | ||
'allowArrowFunctions': true, | ||
'allowBind': true, | ||
}], | ||
"react/jsx-no-bind": [ | ||
1, | ||
{ | ||
ignoreRefs: true, | ||
allowArrowFunctions: true, | ||
allowBind: true, | ||
}, | ||
], | ||
// Prevent duplicate props in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md | ||
'react/jsx-no-duplicate-props': [1, { 'ignoreCase': false }], | ||
"react/jsx-no-duplicate-props": [1, { ignoreCase: false }], | ||
// Prevent usage of unwrapped JSX strings | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md | ||
'react/jsx-no-literals': 0, | ||
"react/jsx-no-literals": 0, | ||
// Disallow undeclared variables in JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md | ||
'react/jsx-no-undef': 1, | ||
"react/jsx-no-undef": 1, | ||
// Enforce PascalCase for user-defined JSX components | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md | ||
'react/jsx-pascal-case': [1, { allowAllCaps: true }], | ||
"react/jsx-pascal-case": [1, { allowAllCaps: true }], | ||
// Enforce propTypes declarations alphabetical sorting | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md | ||
'react/sort-prop-types': [0, { | ||
'ignoreCase': false, | ||
'callbacksLast': false, | ||
}], | ||
"react/sort-prop-types": [ | ||
0, | ||
{ | ||
ignoreCase: false, | ||
callbacksLast: false, | ||
}, | ||
], | ||
// Enforce props alphabetical sorting | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md | ||
'react/jsx-sort-props': [0, { | ||
'ignoreCase': false, | ||
'callbacksLast': false, | ||
}], | ||
"react/jsx-sort-props": [ | ||
0, | ||
{ | ||
ignoreCase: false, | ||
callbacksLast: false, | ||
}, | ||
], | ||
// Prevent React to be incorrectly marked as unused | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md | ||
'react/jsx-uses-react': [1], | ||
"react/jsx-uses-react": [1], | ||
// Prevent variables used in JSX to be incorrectly marked as unused | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md | ||
'react/jsx-uses-vars': 1, | ||
"react/jsx-uses-vars": 1, | ||
// Prevent usage of dangerous JSX properties | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md | ||
'react/no-danger': 1, | ||
"react/no-danger": 1, | ||
// Prevent usage of deprecated methods | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md | ||
'react/no-deprecated': [1], | ||
"react/no-deprecated": [1], | ||
// Prevent usage of setState in componentDidMount | ||
@@ -159,30 +169,30 @@ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md | ||
// https://github.com/airbnb/javascript/issues/684 | ||
'react/no-did-mount-set-state': [OFF], | ||
"react/no-did-mount-set-state": [OFF], | ||
// Prevent usage of setState in componentDidUpdate | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md | ||
'react/no-did-update-set-state': [ERROR], | ||
"react/no-did-update-set-state": [ERROR], | ||
// Prevent direct mutation of this.state | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md | ||
'react/no-direct-mutation-state': WARN, | ||
"react/no-direct-mutation-state": WARN, | ||
// Prevent usage of isMounted | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md | ||
'react/no-is-mounted': ERROR, | ||
"react/no-is-mounted": ERROR, | ||
// Prevent multiple component definition per file | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md | ||
'react/no-multi-comp': [1, { 'ignoreStateless': true }], | ||
"react/no-multi-comp": [1, { ignoreStateless: true }], | ||
// Prevent usage of setState | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md | ||
'react/no-set-state': OFF, | ||
"react/no-set-state": OFF, | ||
// Prevent using string references | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md | ||
'react/no-string-refs': OFF, | ||
"react/no-string-refs": OFF, | ||
// Prevent usage of unknown DOM property | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md | ||
'react/no-unknown-property': ERROR, | ||
"react/no-unknown-property": ERROR, | ||
// Require ES6 class declarations over React.createClass | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md | ||
'react/prefer-es6-class': [ERROR, 'always'], | ||
"react/prefer-es6-class": [ERROR, "always"], | ||
// Require stateless functions when not using lifecycle methods, setState or ref | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md | ||
'react/prefer-stateless-function': ERROR, | ||
"react/prefer-stateless-function": ERROR, | ||
// Prevent missing props validation in a React component definition | ||
@@ -193,3 +203,3 @@ // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md | ||
'react/react-in-jsx-scope': ERROR, | ||
"react/react-in-jsx-scope": ERROR, | ||
@@ -204,44 +214,53 @@ // Restrict file extensions that may be required | ||
// NOTE: Does not work properly at all times | ||
'react/require-render-return': OFF, | ||
"react/require-render-return": OFF, | ||
// Prevent extra closing tags for components without children | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md | ||
'react/self-closing-comp': WARN, | ||
"react/self-closing-comp": WARN, | ||
// Enforce spaces before the closing bracket of self-closing JSX elements | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md | ||
'react/jsx-tag-spacing': [WARN, { | ||
'beforeSelfClosing': "always", | ||
}], | ||
"react/jsx-tag-spacing": [ | ||
WARN, | ||
{ | ||
beforeSelfClosing: "always", | ||
}, | ||
], | ||
// Enforce component methods order | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md | ||
'react/sort-comp': [WARN, { | ||
'order': [ | ||
'static-methods', | ||
'lifecycle', | ||
'/^on.+$/', | ||
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', | ||
'everything-else', | ||
'/^render.+$/', | ||
'render' | ||
] | ||
}], | ||
"react/sort-comp": [ | ||
WARN, | ||
{ | ||
order: [ | ||
"static-methods", | ||
"lifecycle", | ||
"/^on.+$/", | ||
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/", | ||
"everything-else", | ||
"/^render.+$/", | ||
"render", | ||
], | ||
}, | ||
], | ||
// Prevent missing parentheses around multilines JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md | ||
'react/wrap-multilines': [WARN, { | ||
declaration: true, | ||
assignment: true, | ||
return: true | ||
}], | ||
'react/wrap-multilines': 0, // deprecated version | ||
"react/wrap-multilines": [ | ||
WARN, | ||
{ | ||
declaration: true, | ||
assignment: true, | ||
return: true, | ||
}, | ||
], | ||
"react/wrap-multilines": 0, // deprecated version | ||
// Require that the first prop in a JSX element be on a new line when the element is multiline | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md | ||
'react/jsx-first-prop-new-line': [WARN, 'multiline'], | ||
"react/jsx-first-prop-new-line": [WARN, "multiline"], | ||
// Enforce spacing around jsx equals signs | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md | ||
'react/jsx-equals-spacing': [WARN, 'never'], | ||
"react/jsx-equals-spacing": [WARN, "never"], | ||
// Enforce JSX indentation | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md | ||
'react/jsx-indent': [WARN, 2], | ||
"react/jsx-indent": [WARN, 2], | ||
@@ -251,12 +270,12 @@ // Disallow target="_blank" on links | ||
// This rules requires that you accompany all target='_blank' attributes with rel='noreferrer noopener'. | ||
'react/jsx-no-target-blank': WARN, | ||
"react/jsx-no-target-blank": WARN, | ||
// only .jsx files may have JSX | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md | ||
'react/jsx-filename-extension': [OFF, { extensions: ['.jsx'] }], | ||
"react/jsx-filename-extension": [OFF, { extensions: [".jsx"] }], | ||
// prevent accidental JS comments from being injected into JSX as text | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md | ||
'react/jsx-no-comment-textnodes': ERROR, | ||
'react/no-comment-textnodes': 0, // deprecated version | ||
"react/jsx-no-comment-textnodes": ERROR, | ||
"react/no-comment-textnodes": 0, // deprecated version | ||
@@ -266,30 +285,29 @@ // disallow using React.render/ReactDOM.render's return value | ||
// TODO: on it later | ||
'react/no-render-return-value': OFF, | ||
"react/no-render-return-value": OFF, | ||
// require a shouldComponentUpdate method, or PureRenderMixin | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md | ||
'react/require-optimization': [OFF, { allowDecorators: [] }], | ||
"react/require-optimization": [OFF, { allowDecorators: [] }], | ||
// warn against using findDOMNode() | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md | ||
'react/no-find-dom-node': OFF, | ||
"react/no-find-dom-node": OFF, | ||
// https://www.npmjs.com/package/eslint-plugin-react-hooks | ||
'react-hooks/rules-of-hooks': ERROR, | ||
'react-hooks/exhaustive-deps': OFF, | ||
"react-hooks/rules-of-hooks": ERROR, | ||
"react-hooks/exhaustive-deps": OFF, | ||
'react/no-typos': 'error', | ||
"react/no-typos": "error", | ||
// Prevent unused state values | ||
// https://github.com/yannickcr/eslint-plugin-react/pull/1103/ | ||
'react/no-unused-state': 'error', | ||
// https://github.com/yannickcr/eslint-plugin-react/pull/1103/ | ||
"react/no-unused-state": "error", | ||
// Prevent usage of shouldComponentUpdate when extending React.PureComponent | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md | ||
'react/no-redundant-should-component-update': 'error', | ||
"react/no-redundant-should-component-update": "error", | ||
// Prevent void DOM elements from receiving children | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md | ||
'react/void-dom-elements-no-children': 'error', | ||
"react/void-dom-elements-no-children": "error", | ||
@@ -300,41 +318,44 @@ // Forbids using non-exported propTypes | ||
// but it's only critical if you're stripping propTypes in production. | ||
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], | ||
"react/forbid-foreign-prop-types": ["warn", { allowInPropTypes: true }], | ||
// Prevent usage of Array index in keys | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md | ||
'react/no-array-index-key': 'error', | ||
"react/no-array-index-key": "error", | ||
// Prevent passing of children as props | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md | ||
'react/no-children-prop': 'error', | ||
"react/no-children-prop": "error", | ||
// Require style prop value be an object or var | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md | ||
'react/style-prop-object': 'error', | ||
"react/style-prop-object": "error", | ||
// Prevent unused propType definitions | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md | ||
'react/no-unused-prop-types': ['error', { | ||
customValidators: [ | ||
], | ||
skipShapeProps: true, | ||
}], | ||
"react/no-unused-prop-types": [ | ||
"error", | ||
{ | ||
customValidators: [], | ||
skipShapeProps: true, | ||
}, | ||
], | ||
// Prevent problem with children and props.dangerouslySetInnerHTML | ||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md | ||
'react/no-danger-with-children': 'error', | ||
"react/no-danger-with-children": "error", | ||
"react-refresh/only-export-components": "error" | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
"import/resolver": { | ||
node: { | ||
extensions: ['.js', '.jsx', '.json'] | ||
} | ||
extensions: [".js", ".jsx", ".json"], | ||
}, | ||
}, | ||
react: { | ||
pragma: 'React', | ||
version: '0.15' | ||
pragma: "React", | ||
version: "0.15", | ||
}, | ||
} | ||
}, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55090
1199
71