diff --git a/.eslintrc b/.eslintrc index 6d549eac2..acc07069d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,18 @@ { "env": { - "jest/globals": true + "jest/globals": true, }, - "extends": ["airbnb","react-app", "plugin:jest-dom/recommended", "plugin:testing-library/react"], + "parser": '@babel/eslint-parser', + "parserOptions": { + sourceType: 'module', + }, + "extends": [ + "airbnb", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:jest-dom/recommended", + "plugin:testing-library/react" + ], "globals": { "page": true, "document": true @@ -14,6 +24,32 @@ ], "import/prefer-default-export": "off", "no-console": "off", + "no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }], + 'no-unused-vars': 'off', + 'no-undef': 'off', + 'no-restricted-syntax': ['warn', 'WithStatement'], + 'no-restricted-globals': ['error'], + eqeqeq: ['warn', 'smart'], + 'no-use-before-define': [ + 'warn', + { + functions: false, + classes: false, + variables: false, + }, + ], + 'no-mixed-operators': [ + 'warn', + { + groups: [ + ['&', '|', '^', '~', '<<', '>>', '>>>'], + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + ['&&', '||'], + ['in', 'instanceof'], + ], + allowSamePrecedence: false, + }, + ], "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], "require-jsdoc": ["error", { "require": { diff --git a/package.json b/package.json index b2ef3d72b..6a05043cb 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "devDependencies": { "@babel/cli": "^7.22.10", "@babel/core": "^7.22.10", + "@babel/eslint-parser": "^7.25.9", "@babel/plugin-transform-regenerator": "^7.22.10", "@babel/plugin-transform-runtime": "^7.22.10", "@babel/preset-env": "^7.22.10", @@ -104,7 +105,6 @@ "core-js": "^3.21.1", "eslint": "^8.11.0", "eslint-config-airbnb": "^19.0.4", - "eslint-config-react-app": "^7.0.0", "eslint-plugin-flowtype": "^8.0.3", "eslint-plugin-import": "^2.25.4", "eslint-plugin-jest": "^27.1.5", diff --git a/src/components/PluginHook.js b/src/components/PluginHook.js index 0119fcf08..c3817d851 100644 --- a/src/components/PluginHook.js +++ b/src/components/PluginHook.js @@ -18,3 +18,5 @@ export const PluginHook = forwardRef((props, ref) => { )) ) : null; }); + +PluginHook.displayName = 'PluginHook'; diff --git a/src/containers/WorkspaceAddButton.js b/src/containers/WorkspaceAddButton.js index cec63fcb4..a015bcc6d 100644 --- a/src/containers/WorkspaceAddButton.js +++ b/src/containers/WorkspaceAddButton.js @@ -25,6 +25,7 @@ function useWidth() { ); } +/* eslint react/display-name: "off" */ /** * withWidth * @memberof WorkspaceControlPanel diff --git a/src/extend/withRef.js b/src/extend/withRef.js index 3048a34bf..165bdf367 100644 --- a/src/extend/withRef.js +++ b/src/extend/withRef.js @@ -5,5 +5,6 @@ export const withRef = () => (Component) => { const WithRefs = forwardRef((props, ref) => ( )); + WithRefs.displayName = 'WithRefs'; return WithRefs; }; diff --git a/src/lib/CanvasWorld.js b/src/lib/CanvasWorld.js index 7df30b020..bd0948474 100644 --- a/src/lib/CanvasWorld.js +++ b/src/lib/CanvasWorld.js @@ -38,7 +38,7 @@ export default class CanvasWorld { let canvasHeight = 0; let canvasWidth = 0; - if (!isNaN(canvas.aspectRatio)) { + if (!Number.isNaN(canvas.aspectRatio)) { if (dirY === 0) { // constant height canvasHeight = scale;