From 6e02f1d19495250ce447d7c79bf07a036cfc5012 Mon Sep 17 00:00:00 2001 From: Maciej Lenartowicz Date: Wed, 13 Nov 2019 10:11:11 +0000 Subject: [PATCH] Shared lint configs --- .eslintrc.js | 64 +------------------------ package-lock.json | 94 ++++++++++++++++++++++++++++++------- package.json | 7 +-- src/bootstrap/EmailInput.js | 1 - src/bootstrap/Modal.js | 1 - src/bootstrap/RadioSet.js | 1 - src/bootstrap/Select.js | 1 - src/bootstrap/TextInput.js | 2 - src/form/hooks.js | 1 - src/validations.js | 1 - 10 files changed, 80 insertions(+), 93 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d783c34..9ca1dc3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,66 +1,6 @@ -const path = require("path"); - module.exports = { - "env": { - "browser": true, - "node": true, - "es6": true, - "jest": true - }, - "extends": [ - "airbnb", - "airbnb/hooks" - ], - "globals": { - "_": "readonly", - "babel": "readonly", - "ForisTranslations": "readonly", - "ngettext": "readonly", - "ForisPlugins": "readonly" - }, - "parser": "babel-eslint", - "rules": { - "quotes": ["error", "double"], - "indent": ["error", 4], - "react/jsx-indent": ["error", 4], - "react/jsx-indent-props": ["error", 4], - "react/prop-types": "warn", - "react/no-array-index-key": "warn", - "react/button-has-type": "warn", + extends: "eslint-config-reforis", + rules: { "import/prefer-default-export": "off", - "import/no-unresolved": [ - "error", - // Ignore imports used only in tests - { ignore: ["customTestRender"] } - ], - "import/no-cycle": "warn", - "no-console": "error", - "no-use-before-define": ["error", { - functions: false, - classes: true, - variables: true - }], - "no-restricted-syntax": "warn", - // Should be enabled in the future - "camelcase": "off", - "no-param-reassign": "off", - "react/jsx-props-no-spreading": "off", - "react/require-default-props": "off", - "react/default-props-match-prop-types": "off", - "react/forbid-prop-types": "off", - // Permanently disabled - "react/jsx-filename-extension": "off", - "no-plusplus": "off", - "consistent-return": "off", - "radix": "off", - "no-continue": "off", - "react/no-danger": "off", }, - "settings": { - "import/resolver": { - "node": { - "paths": ["src"] - } - } - } }; diff --git a/package-lock.json b/package-lock.json index 2d3efca..c8ff325 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3001,9 +3001,9 @@ } }, "confusing-browser-globals": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.8.tgz", - "integrity": "sha512-lI7asCibVJ6Qd3FGU7mu4sfG4try4LX3+GVS+Gv8UlrEf2AeW57piecapnog2UHZSbcX/P/1UDWVaTsblowlZg==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", + "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==", "dev": true }, "connect-history-api-fallback": { @@ -4098,6 +4098,20 @@ "object.entries": "^1.1.0" } }, + "eslint-config-reforis": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-reforis/-/eslint-config-reforis-1.0.0.tgz", + "integrity": "sha512-c0IgYlGfFMfhXmGilDVgkFIcUU34/i6wUiOzdRmg0CRi2Ko5LgmW/jRT5vdiXlFKYOk5WK1UWFbC19KBdGQEig==", + "dev": true, + "requires": { + "babel-eslint": "^9.0.0", + "eslint-config-airbnb": "^18.0.1", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.14.3", + "eslint-plugin-react-hooks": "^1.7.0" + } + }, "eslint-import-resolver-node": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", @@ -4356,20 +4370,20 @@ } }, "eslint-plugin-react": { - "version": "7.14.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.14.3.tgz", - "integrity": "sha512-EzdyyBWC4Uz2hPYBiEJrKCUi2Fn+BJ9B/pJQcjw5X+x/H2Nm59S4MJIvL4O5NEE0+WbnQwEBxWY03oUk+Bc3FA==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz", + "integrity": "sha512-GacBAATewhhptbK3/vTP09CbFrgUJmBSaaRcWdbQLFvUZy9yVcQxigBNHGPU/KE2AyHpzj3AWXpxoMTsIDiHug==", "dev": true, "requires": { "array-includes": "^3.0.3", "doctrine": "^2.1.0", "has": "^1.0.3", - "jsx-ast-utils": "^2.1.0", + "jsx-ast-utils": "^2.2.1", "object.entries": "^1.1.0", "object.fromentries": "^2.0.0", "object.values": "^1.1.0", "prop-types": "^15.7.2", - "resolve": "^1.10.1" + "resolve": "^1.12.0" }, "dependencies": { "doctrine": { @@ -7546,9 +7560,9 @@ } }, "jsx-ast-utils": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.1.tgz", - "integrity": "sha512-v3FxCcAf20DayI+uxnCuw795+oOIkVu6EnJ1+kSzhqqTZHNkTZ7B66ZgLp4oLJ/gbA64cI0B7WRoHZMSRdyVRQ==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz", + "integrity": "sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -8345,6 +8359,12 @@ } } }, + "object-inspect": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", + "dev": true + }, "object-is": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.0.1.tgz", @@ -8391,15 +8411,35 @@ } }, "object.fromentries": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.0.tgz", - "integrity": "sha512-9iLiI6H083uiqUuvzyY6qrlmc/Gz8hLQFOcb/Ri/0xXFkSNS3ctV+CbE6yM2+AnkYfOB3dGjdzC0wrMLIhQICA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.1.tgz", + "integrity": "sha512-PUQv8Hbg3j2QX0IQYv3iAGCbGcu4yY4KQ92/dhA4sFSixBmSmp13UpDLs6jGK8rBtbmhNNIK99LD2k293jpiGA==", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.11.0", + "define-properties": "^1.1.3", + "es-abstract": "^1.15.0", "function-bind": "^1.1.1", - "has": "^1.0.1" + "has": "^1.0.3" + }, + "dependencies": { + "es-abstract": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz", + "integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.0", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-inspect": "^1.6.0", + "object-keys": "^1.1.1", + "string.prototype.trimleft": "^2.1.0", + "string.prototype.trimright": "^2.1.0" + } + } } }, "object.getownpropertydescriptors": { @@ -11163,6 +11203,26 @@ "strip-ansi": "^4.0.0" } }, + "string.prototype.trimleft": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", + "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, + "string.prototype.trimright": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", + "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "function-bind": "^1.1.1" + } + }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", diff --git a/package.json b/package.json index ce38bc6..2e72014 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@babel/preset-react": "^7.0.0", "@fortawesome/fontawesome-free": "^5.11.2", "@testing-library/react": "^8.0.9", - "babel-eslint": "^9.0.0", "babel-jest": "^24.8.0", "babel-loader": "^8.0.6", "babel-plugin-module-resolver": "^3.2.0", @@ -48,11 +47,7 @@ "copy-webpack-plugin": "^5.0.4", "css-loader": "^3.2.0", "eslint": "^6.1.0", - "eslint-config-airbnb": "^18.0.1", - "eslint-plugin-import": "^2.18.2", - "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.3", - "eslint-plugin-react-hooks": "^1.7.0", + "eslint-config-reforis": "^1.0.0", "file-loader": "^4.2.0", "jest": "^24.8.0", "jest-mock-axios": "^3.0.0", diff --git a/src/bootstrap/EmailInput.js b/src/bootstrap/EmailInput.js index 9e499cd..44e78de 100644 --- a/src/bootstrap/EmailInput.js +++ b/src/bootstrap/EmailInput.js @@ -12,7 +12,6 @@ import { Input } from "./Input"; export const EmailInput = ({ ...props }) => ; - EmailInput.propTypes = { /** Field label. */ label: PropTypes.string.isRequired, diff --git a/src/bootstrap/Modal.js b/src/bootstrap/Modal.js index 4fc381f..a212c1f 100644 --- a/src/bootstrap/Modal.js +++ b/src/bootstrap/Modal.js @@ -37,7 +37,6 @@ export function Modal({ shown, setShown, children }) { }; }, [setShown]); - return (
diff --git a/src/bootstrap/RadioSet.js b/src/bootstrap/RadioSet.js index 48017a4..63af8f0 100644 --- a/src/bootstrap/RadioSet.js +++ b/src/bootstrap/RadioSet.js @@ -11,7 +11,6 @@ import { useUID } from "react-uid"; import { formFieldsSize } from "./constants"; - RadioSet.propTypes = { /** Name attribute of the input HTML tag. */ name: PropTypes.string.isRequired, diff --git a/src/bootstrap/Select.js b/src/bootstrap/Select.js index bc524c4..0d90752 100644 --- a/src/bootstrap/Select.js +++ b/src/bootstrap/Select.js @@ -9,7 +9,6 @@ import React from "react"; import PropTypes from "prop-types"; import { useUID } from "react-uid"; - Select.propTypes = { /** Select field Label. */ label: PropTypes.string.isRequired, diff --git a/src/bootstrap/TextInput.js b/src/bootstrap/TextInput.js index 137e114..be60bb6 100644 --- a/src/bootstrap/TextInput.js +++ b/src/bootstrap/TextInput.js @@ -10,10 +10,8 @@ import PropTypes from "prop-types"; import { Input } from "./Input"; - export const TextInput = ({ ...props }) => ; - TextInput.propTypes = { /** Field label. */ label: PropTypes.string.isRequired, diff --git a/src/form/hooks.js b/src/form/hooks.js index ebc48c5..f91b5da 100644 --- a/src/form/hooks.js +++ b/src/form/hooks.js @@ -48,7 +48,6 @@ export function useForm(validator, dataPreprocessor) { ]; } - function formReducer(state, action) { switch (action.type) { case FORM_ACTIONS.updateValue: { diff --git a/src/validations.js b/src/validations.js index 692d005..2af2855 100644 --- a/src/validations.js +++ b/src/validations.js @@ -29,7 +29,6 @@ const REs = { MultipleEmails: /^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)( *, *[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ *)*$/, }; - const createValidator = (fieldType) => (value) => { if (value && value !== "") return REs[fieldType].test(value) ? undefined : ERROR_MESSAGES[fieldType]; };