From e3b5a1f088a90af62e2971f254dced95811abd3a Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Fri, 4 Oct 2024 12:32:07 -0700 Subject: [PATCH] chore(deps): upgrade to @edx/eslint-config 4.2 --- .eslintrc.js | 15 ++----- package-lock.json | 43 ++++++++++++++++--- package.json | 2 +- .../tests/ControlledSelectHeader.test.jsx | 14 +++--- .../{Truncate.test.js => utils.test.js} | 0 src/hooks/useArrowKeyNavigation.jsx | 3 +- tsconfig.build.json | 4 +- tsconfig.json | 12 +++++- www/src/components/LeaveFeedback.tsx | 2 +- www/src/components/Menu.tsx | 2 +- www/tsconfig.json | 2 +- 11 files changed, 66 insertions(+), 33 deletions(-) rename src/Truncate/{Truncate.test.js => utils.test.js} (100%) diff --git a/.eslintrc.js b/.eslintrc.js index aaf4750116..aec82a5036 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,9 +3,9 @@ const path = require('path'); module.exports = { extends: [ '@edx/eslint-config', - 'plugin:import/typescript', ], - parser: '@babel/eslint-parser', + plugins: ['@typescript-eslint'], + parser: '@typescript-eslint/parser', parserOptions: { requireConfigFile: true, babelOptions: { @@ -30,7 +30,9 @@ module.exports = { '**/*.stories.jsx', 'src/setupTest.ts', '**/*.test.jsx', + '**/*.test.tsx', '**/*.test.js', + '**/*.test.ts', 'config/*.js', '*.config.ts', '*.config.*.js', @@ -62,13 +64,4 @@ module.exports = { globals: { newrelic: false, }, - overrides: [ - { - files: ['**/*.ts', '**/*.tsx'], - extends: 'airbnb-typescript', - parserOptions: { - project: './tsconfig.json', - }, - }, - ], }; diff --git a/package-lock.json b/package-lock.json index 948b628993..46613e952f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,7 +58,7 @@ "@babel/preset-env": "^7.16.8", "@babel/preset-react": "^7.16.7", "@babel/preset-typescript": "^7.16.7", - "@edx/eslint-config": "^3.2.0", + "@edx/eslint-config": "^4.2.0", "@edx/stylelint-config-edx": "^2.3.0", "@edx/typescript-config": "^1.0.1", "@formatjs/cli": "^5.0.2", @@ -2368,14 +2368,17 @@ "license": "UNLICENSED" }, "node_modules/@edx/eslint-config": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@edx/eslint-config/-/eslint-config-3.2.0.tgz", - "integrity": "sha512-X2o34xr3KqmQSV/vJVv6k4FxUKYwbBATHTtTHLTYQvM9PVoM3WbKQP9tl6Z057pRErKzshJcks+4ENzDyhr11Q==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@edx/eslint-config/-/eslint-config-4.2.0.tgz", + "integrity": "sha512-2wuIw49uyj6gRwS74qJ8WhBU+X2FOP4uot40sthIC4YU9qCM7WJOcOuAhkRPP1FvZKd3UQH3gZM7eJ85xzDBqA==", "dev": true, "peerDependencies": { - "eslint": "^6.8.0 || ^7.0.0 || ^8.0.0", + "@typescript-eslint/eslint-plugin": "^5.62.0", + "@typescript-eslint/parser": "^5.62.0", + "eslint": "^7.32.0 || ^8.2.0", "eslint-config-airbnb": "^18.0.1 || ^19.0.0", - "eslint-plugin-import": "^2.20.0", + "eslint-config-airbnb-typescript": "^17.0.0", + "eslint-plugin-import": "^2.25.3", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.18.0", "eslint-plugin-react-hooks": "^1.7.0 || ^4.0.0" @@ -2477,6 +2480,20 @@ "url": "https://opencollective.com/babel" } }, + "node_modules/@edx/frontend-build/node_modules/@edx/eslint-config": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@edx/eslint-config/-/eslint-config-3.2.0.tgz", + "integrity": "sha512-X2o34xr3KqmQSV/vJVv6k4FxUKYwbBATHTtTHLTYQvM9PVoM3WbKQP9tl6Z057pRErKzshJcks+4ENzDyhr11Q==", + "dev": true, + "peerDependencies": { + "eslint": "^6.8.0 || ^7.0.0 || ^8.0.0", + "eslint-config-airbnb": "^18.0.1 || ^19.0.0", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.18.0", + "eslint-plugin-react-hooks": "^1.7.0 || ^4.0.0" + } + }, "node_modules/@edx/frontend-build/node_modules/@eslint/eslintrc": { "version": "2.0.2", "dev": true, @@ -40071,6 +40088,20 @@ "playroom": "^0.31.0" } }, + "www/node_modules/@edx/eslint-config": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@edx/eslint-config/-/eslint-config-3.2.0.tgz", + "integrity": "sha512-X2o34xr3KqmQSV/vJVv6k4FxUKYwbBATHTtTHLTYQvM9PVoM3WbKQP9tl6Z057pRErKzshJcks+4ENzDyhr11Q==", + "dev": true, + "peerDependencies": { + "eslint": "^6.8.0 || ^7.0.0 || ^8.0.0", + "eslint-config-airbnb": "^18.0.1 || ^19.0.0", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.18.0", + "eslint-plugin-react-hooks": "^1.7.0 || ^4.0.0" + } + }, "www/node_modules/decode-uri-component": { "version": "0.4.1", "license": "MIT", diff --git a/package.json b/package.json index edbf3235bf..4e8f977aa1 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "@babel/preset-env": "^7.16.8", "@babel/preset-react": "^7.16.7", "@babel/preset-typescript": "^7.16.7", - "@edx/eslint-config": "^3.2.0", + "@edx/eslint-config": "^4.2.0", "@edx/stylelint-config-edx": "^2.3.0", "@edx/typescript-config": "^1.0.1", "@formatjs/cli": "^5.0.2", diff --git a/src/DataTable/selection/tests/ControlledSelectHeader.test.jsx b/src/DataTable/selection/tests/ControlledSelectHeader.test.jsx index 732c3cdb43..2af2b283ba 100644 --- a/src/DataTable/selection/tests/ControlledSelectHeader.test.jsx +++ b/src/DataTable/selection/tests/ControlledSelectHeader.test.jsx @@ -8,6 +8,13 @@ import DataTableContext from '../../DataTableContext'; import * as selectActions from '../data/actions'; import { getRowIds } from '../data/helpers'; +function DataTableContextChild() { + const contextValue = useContext(DataTableContext); + return ( +
+ ); +} + // eslint-disable-next-line react/prop-types function ControlledSelectHeaderWrapper({ tableProps, selectProps, ...rest }) { return ( @@ -18,13 +25,6 @@ function ControlledSelectHeaderWrapper({ tableProps, selectProps, ...rest }) { ); } -function DataTableContextChild() { - const contextValue = useContext(DataTableContext); - return ( -
- ); -} - const mockToggleAllPageRowsSelectedProps = jest.fn(); const rows = [{ id: 1 }, { id: 2 }]; const tableProps = { diff --git a/src/Truncate/Truncate.test.js b/src/Truncate/utils.test.js similarity index 100% rename from src/Truncate/Truncate.test.js rename to src/Truncate/utils.test.js diff --git a/src/hooks/useArrowKeyNavigation.jsx b/src/hooks/useArrowKeyNavigation.jsx index 69b3bb6cbc..bdfe258b2f 100644 --- a/src/hooks/useArrowKeyNavigation.jsx +++ b/src/hooks/useArrowKeyNavigation.jsx @@ -32,8 +32,7 @@ function handleArrowKey({ event, currentIndex, availableElements }) { [nextElement] = availableElements; } - // eslint-disable-next-line no-unused-expressions - nextElement && nextElement.focus(); + nextElement?.focus(); event.preventDefault(); } diff --git a/tsconfig.build.json b/tsconfig.build.json index 920c37bcae..b4586548d2 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -3,8 +3,10 @@ "compilerOptions": { // For build purposes, we use TypeScript/tsc to generate the .d.ts files and Babel to convert .tsx/.ts/.jsx to .js // In the future we could probably just use tsc for both though. - "emitDeclarationOnly": true + "emitDeclarationOnly": true, + "rootDir": "src" }, + "include": ["src"], // Don't include the .test.tsx files when we build the .d.ts files in dist/ "exclude": ["src/**/*.test.tsx"], } diff --git a/tsconfig.json b/tsconfig.json index 42f8fd340c..5677492e19 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,16 @@ "compilerOptions": { "noImplicitAny": true, "allowJs": false, - "rootDir": "src", "outDir": "dist" }, - "include": ["src"] + "include": [ + "lib/**/*", + "src/**/*", + "*.js", + ".eslintrc.js", + "__mocks__/*", + "algolia-docsearch/*", + "bin/*", + "dependent-usage-analyzer/**/*" + ] } diff --git a/www/src/components/LeaveFeedback.tsx b/www/src/components/LeaveFeedback.tsx index dc39cbb466..d446cc391b 100644 --- a/www/src/components/LeaveFeedback.tsx +++ b/www/src/components/LeaveFeedback.tsx @@ -1,6 +1,6 @@ import React, { AnchorHTMLAttributes } from 'react'; import PropTypes from 'prop-types'; -import { useLocation } from '@reach/router'; +import { useLocation } from '@gatsbyjs/reach-router'; import { Nav, Button, Hyperlink } from '~paragon-react'; import { LEAVE_FEEDBACK_CLICKED_EVENT, sendUserAnalyticsEvent } from '../../segment-events'; diff --git a/www/src/components/Menu.tsx b/www/src/components/Menu.tsx index db01b84e87..2e2efdb7fa 100644 --- a/www/src/components/Menu.tsx +++ b/www/src/components/Menu.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react'; -import { useLocation } from '@reach/router'; +import { useLocation } from '@gatsbyjs/reach-router'; import PropTypes from 'prop-types'; import { Link, graphql, useStaticQuery } from 'gatsby'; import classNames from 'classnames'; diff --git a/www/tsconfig.json b/www/tsconfig.json index 6949812b78..dcbfc7f78b 100644 --- a/www/tsconfig.json +++ b/www/tsconfig.json @@ -10,5 +10,5 @@ "~paragon-icons": ["../icons"], } }, - "include": ["src"] + "include": ["src", "playroom", "utils", "netlify", ".eslintrc.js", "*.js", "*.ts", "*.jsx", "*.tsx"] }