diff --git a/package.json b/package.json index 3ef95b4243..ac2a2d7953 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@geosolutions/acorn-jsx": "4.0.2", "@geosolutions/jsdoc": "3.4.4", "@geosolutions/mocha": "6.2.1-3", - "@mapstore/eslint-config-mapstore": "1.0.5", + "@mapstore/eslint-config-mapstore": "file:./utility/eslint", "@testing-library/react": "12.1.5", "axios-mock-adapter": "1.16.0", "babel-loader": "8.0.5", @@ -69,7 +69,7 @@ "eslint": "7.8.1", "eslint-plugin-import": "2.20.2", "eslint-plugin-no-only-tests": "2.3.1", - "eslint-plugin-react": "3.3.2", + "eslint-plugin-react": "7.31.11", "expect": "1.20.1", "file-loader": "2.0.0", "glob": "7.1.1", diff --git a/utility/eslint/index.js b/utility/eslint/index.js index 8400a7232b..c314e87f52 100644 --- a/utility/eslint/index.js +++ b/utility/eslint/index.js @@ -1,3 +1,4 @@ + module.exports = { "parser": "@babel/eslint-parser", // https://github.com/babel/babel-eslint "parserOptions": { @@ -189,7 +190,7 @@ module.exports = { "react/jsx-no-duplicate-props": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md "react/display-name": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md "react/jsx-boolean-value": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md - "react/jsx-quotes": [2, "double"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-quotes.md + "jsx-quotes": [ 2, "prefer-double" ], // https://eslint.org/docs/latest/rules/jsx-quotesjsx-quotes.md "react/jsx-no-undef": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md "react/jsx-sort-props": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md "react/jsx-sort-prop-types": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-prop-types.md @@ -199,54 +200,61 @@ module.exports = { "react/no-did-update-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md "react/no-multi-comp": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md "react/no-unknown-property": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md + "react/no-unused-prop-types": 2, // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md "react/prop-types": [2, { "ignore": ["children"] }], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md "react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md "react/self-closing-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md - "react/wrap-multilines": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md - "react/sort-comp": [2, { // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md + "react/jsx-wrap-multilines": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md + "react/sort-comp": [2, { "order": [ - "displayName", - "propTypes", - "inheritedPropTypes", - "contextTypes", - "childContextTypes", - "mixins", - "statics", - "defaultProps", - "constructor", - "getDefaultProps", - "/^state$/", - "getInitialState", - "getChildContext", - "UNSAFE_componentWillMount", - "componentWillMount", - "componentDidMount", - "UNSAFE_componentWillReceiveProps", - "componentWillReceiveProps", - "shouldComponentUpdate", - "UNSAFE_componentWillUpdate", - "componentWillUpdate", - "componentDidUpdate", - "componentWillUnmount", - "/^on.+$/", - "/^get.+$/", - "/^render.+$/", - "render" - ], - // CUSTOM - // prevent to `import _ from 'lodash';`. Allows `import {get} from 'lodash';` or `import get from 'lodash/get';` - // for bundle size - "no-restricted-imports": [2, - { - "name": "lodash", - "importNames": ["default"], - "message": "Please use the default import from 'lodash/functionName' instead." - } + 'static-methods', + 'lifecycle', + 'everything-else', + 'render' ], - // prevent to `const _ = require('lodash')`. Allows `const get = require('lodash/get');` - // for bundle size - "no-restricted-modules": [2, { "paths": ["lodash", "!lodash/*"] }] - }] - } -}; + "groups": { + "lifecycle": [ + 'displayName', + 'propTypes', + 'contextTypes', + 'childContextTypes', + 'mixins', + 'statics', + 'defaultProps', + 'constructor', + 'getDefaultProps', + 'state', + 'getInitialState', + 'getChildContext', + 'getDerivedStateFromProps', + 'componentWillMount', + 'UNSAFE_componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', + 'getSnapshotBeforeUpdate', + 'componentDidUpdate', + 'componentDidCatch', + 'componentWillUnmount' + ] + } + }], + // CUSTOM + // prevent to `import _ from 'lodash';`. Allows `import {get} from 'lodash';` or `import get from 'lodash/get';` + // for bundle size + "no-restricted-imports": [2, + { + "name": "lodash", + "importNames": ["default"], + "message": "Please use the default import from 'lodash/functionName' instead." + } + ], + // prevent to `const _ = require('lodash')`. Allows `const get = require('lodash/get');` + // for bundle size + "no-restricted-modules": [2, { "paths": ["lodash"], "patterns": ["!lodash/*"]}] + } +}; diff --git a/utility/eslint/package.json b/utility/eslint/package.json index b76c5def6e..6bdb1c7da0 100644 --- a/utility/eslint/package.json +++ b/utility/eslint/package.json @@ -1,6 +1,6 @@ { "name": "@mapstore/eslint-config-mapstore", - "version": "1.0.5", + "version": "1.0.6", "private": false, "description": "ESLint Configuration for MapStore project", "author": "GeoSolutions S.a.s.", @@ -29,6 +29,6 @@ "eslint": ">= 7.5.0", "eslint-plugin-import": ">= 2.20.2", "eslint-plugin-no-only-tests": ">= 2.3.1", - "eslint-plugin-react": ">= 3.3.2" + "eslint-plugin-react": ">= 7.31.11" } }