Skip to content

Commit

Permalink
Upgrade to eslint9
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Oct 31, 2024
1 parent 69ff1e4 commit 841c39f
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 108 deletions.
93 changes: 0 additions & 93 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions __tests__/src/components/WorkspaceElastic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('WorkspaceElastic', () => {
setWorkspaceViewportPosition: mockDragStop,
});

/** */
container.getBoundingClientRect = () => ({
left: -2500,
offsetHeight: 5000,
Expand Down
1 change: 1 addition & 0 deletions __tests__/src/components/WorkspaceElasticWindow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('WorkspaceElasticWindow', () => {
updateElasticWindowLayout: mockOnResize,
});

/** */
container.getBoundingClientRect = () => ({
left: -2500,
offsetHeight: 5000,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ function renderWithProviders(
};
}

export * from '@testing-library/react';
export * from '@testing-library/react'; // eslint-disable-line import/export
export { renderWithProviders as render };

Check failure on line 45 in __tests__/utils/test-utils.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Multiple exports of name 'render'

Check failure on line 45 in __tests__/utils/test-utils.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Multiple exports of name 'render'
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const moduleFormatMap = {
es: false,
};

// eslint-disable-next-line func-names
// eslint-disable-next-line jsdoc/require-jsdoc
module.exports = function (api) {
const isDevelopmentEnv = api.env('development');
const isProductionEnv = api.env('production');
Expand Down
140 changes: 140 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import jest from "eslint-plugin-jest";
import jestDom from "eslint-plugin-jest-dom";
import jsxA11y from 'eslint-plugin-jsx-a11y';
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import testingLibrary from "eslint-plugin-testing-library";
import jsdoc from 'eslint-plugin-jsdoc';
import babelParser from "@babel/eslint-parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
allConfig: js.configs.all,
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

export default [{
ignores: ["**/dist/", "**/config/", "**/coverage/", "**/styles/"],
}, ...fixupConfigRules(compat.extends(
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jest-dom/recommended",
"plugin:jsx-a11y/recommended",
"plugin:testing-library/react",
)), {

languageOptions: {
ecmaVersion: 6,
globals: {
...jest.environments.globals.globals,
document: true,
page: true,
},
parser: babelParser,
sourceType: "module",
},
plugins: {
jest,
"jest-dom": fixupPluginRules(jestDom),
jsdoc,
jsxA11y,
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
"testing-library": fixupPluginRules(testingLibrary),
},

rules: {
"arrow-parens": "off",
"default-param-last": "off",
eqeqeq: ["warn", "smart"],
"import/no-anonymous-default-export": "off",


"import/no-unresolved": [2, {
ignore: ["test-utils"],
}],

"import/prefer-default-export": "off",

"jsdoc/require-jsdoc": ["error", {
minLineCount: 6,
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
FunctionDeclaration: true,
FunctionExpression: true,
MethodDefinition: true,
},
}],

"jsx-a11y/no-autofocus": "warn",

"max-len": ["error", {
code: 120,
ignoreComments: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
"no-console": "off",

"no-mixed-operators": ["warn", {
allowSamePrecedence: false,
groups: [
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"],
],
}],
"no-param-reassign": ["error", { "props": false }],

"no-restricted-globals": ["error"],
"no-restricted-syntax": ["warn", "WithStatement"],
"no-undef": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": ["error", {
allowShortCircuit: true,
allowTernary: true,
}],
"no-unused-vars": "off",

"no-use-before-define": ["warn", {
classes: false,
functions: false,
variables: false,
}],

"react-hooks/exhaustive-deps": "error",

"react/function-component-definition": "off",

"react/jsx-filename-extension": [1, {
extensions: [".js", ".jsx"],
}],

"react/jsx-props-no-spreading": "off",
"react/jsx-uses-react": "off",
"react/prefer-stateless-function": "off",
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
"sort-keys": ["error", "asc", {
caseSensitive: false,
natural: false,
}],

"testing-library/no-render-in-lifecycle": ["error", {
allowTestingFrameworkSetupHook: "beforeEach",
}],
"testing-library/render-result-naming-convention": "off",

},
}];
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@
"@babel/plugin-transform-runtime": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.10",
"@eslint/compat": "^1.2.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.4.3",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@typescript-eslint/eslint-plugin": "^8.12.0",
"@typescript-eslint/parser": "^8.12.0",
"babel-jest": "^29.3.1",
"babel-loader": "^9.1.0",
"babel-plugin-lodash": "^3.3.4",
Expand All @@ -103,16 +106,15 @@
"canvas": "^2.11.0",
"chalk": "^4.1.0",
"core-js": "^3.21.1",
"eslint": "^8.11.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^27.1.5",
"eslint": "^9.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest-dom": "^5.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-jsdoc": "^50.4.3",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^6.2.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-testing-library": "^7.0.0-beta.3",
"glob": "^10.3.0",
"http-server": "^14.1.0",
"jest": "^29.3.1",
Expand Down
2 changes: 1 addition & 1 deletion setupJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jest.mock('react-i18next', () => ({
init: jest.fn(),
type: '3rdParty',
},
// this mock makes sure any components using the translate HoC receive the t function as a prop
/** this mock makes sure any components using the translate HoC receive the t function as a prop */
withTranslation: () => (Component) => {
Component.defaultProps = { // eslint-disable-line no-param-reassign
...Component.defaultProps, t: k => k,
Expand Down
2 changes: 1 addition & 1 deletion src/components/GalleryViewThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class GalleryViewThumbnail extends Component {
this.handleIntersection = this.handleIntersection.bind(this);
}

// eslint-disable-next-line require-jsdoc
// eslint-disable-next-line jsdoc/require-jsdoc
componentDidMount() {
const { selected } = this.props;
if (selected) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SidebarIndexList.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class SidebarIndexList extends Component {
<MenuList variant="selectedMenu">
{
canvasesIdAndLabel.map((canvas, canvasIndex) => {
const onClick = () => { setCanvas(windowId, canvas.id); }; // eslint-disable-line require-jsdoc, max-len
const onClick = () => { setCanvas(windowId, canvas.id); }; // eslint-disable-line jsdoc/require-jsdoc, max-len

return (
<ScrollTo
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const baseConfig = mode => ({
},
});

/** */
module.exports = (env, options) => {
const isProduction = options.mode === 'production';
const config = baseConfig(options.mode);
Expand Down

0 comments on commit 841c39f

Please sign in to comment.