From f5abc2e72ce15f79c7e63ebb6d52468145c359bf Mon Sep 17 00:00:00 2001 From: Christian Maddox Date: Thu, 14 Nov 2024 13:35:22 -0500 Subject: [PATCH] chore: Add custom browserslist (#2290) * Add browserslist config. * Integrate browserslistrc w/ eslint and stylelint. * Fix config. * Remove stylelint plugin. * Fix plugin configuration. * Corrected label. * Delete old comment. --- assets/.browserslistrc | 12 +++ assets/babel.config.json | 15 ++++ assets/eslint.config.mjs | 5 ++ assets/package-lock.json | 180 ++++++++++++++++++++++++++++++++++----- assets/package.json | 2 + assets/webpack.config.js | 22 +---- 6 files changed, 196 insertions(+), 40 deletions(-) create mode 100644 assets/.browserslistrc create mode 100644 assets/babel.config.json diff --git a/assets/.browserslistrc b/assets/.browserslistrc new file mode 100644 index 000000000..74a907a9d --- /dev/null +++ b/assets/.browserslistrc @@ -0,0 +1,12 @@ +# DUP +ChromeAndroid 61 +# Sectional (Solari) +Firefox 90 +# Sectional (GDS) +Firefox 126 +# Pre-Fare +Chrome 126 +# Bus Shelter +Firefox 126 +# Bus E-ink (GDS) +Chrome 45 diff --git a/assets/babel.config.json b/assets/babel.config.json new file mode 100644 index 000000000..bb72754df --- /dev/null +++ b/assets/babel.config.json @@ -0,0 +1,15 @@ +{ + "presets": [ + "@babel/preset-env", + "@babel/preset-react", + "@babel/preset-typescript" + ], + "plugins": [ + "@babel/plugin-proposal-export-default-from", + "@babel/plugin-proposal-logical-assignment-operators", + ["@babel/plugin-proposal-optional-chaining", { "loose": false }], + ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], + ["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }], + "@babel/plugin-proposal-do-expressions" + ] +} diff --git a/assets/eslint.config.mjs b/assets/eslint.config.mjs index 6594fb47d..ea3e9a5ac 100644 --- a/assets/eslint.config.mjs +++ b/assets/eslint.config.mjs @@ -5,6 +5,7 @@ import pluginReactConfig from "eslint-plugin-react/configs/recommended.js"; import pluginReactHooks from "eslint-plugin-react-hooks"; import eslintConfigPrettier from "eslint-config-prettier"; import jestPlugin from "eslint-plugin-jest"; +import compat from "eslint-plugin-compat"; export default [ { languageOptions: { globals: globals.browser } }, @@ -48,4 +49,8 @@ export default [ ], }, }, + { + ...compat.configs["flat/recommended"], + files: ["**/*.{ts, tsx}"], + }, ]; diff --git a/assets/package-lock.json b/assets/package-lock.json index 977f1307f..a52f13553 100644 --- a/assets/package-lock.json +++ b/assets/package-lock.json @@ -43,11 +43,13 @@ "@types/react-router-dom": "^5.1.8", "@types/webpack-env": "^1.18.4", "babel-loader": "^8.2.2", + "browserslist": "^4.24.2", "concurrently": "^8.2.2", "copy-webpack-plugin": "^6.4.1", "css-loader": "^5.2.7", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-compat": "^6.0.1", "eslint-plugin-jest": "^28.5.0", "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.2", @@ -3589,6 +3591,13 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mdn/browser-compat-data": { + "version": "5.6.13", + "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-5.6.13.tgz", + "integrity": "sha512-eZOraBiugKZewtS10c7M78OKwL6CBhVzqSQvb5j+WGw/7MdPRfHrP7LuiEoLCeHXfmE414geJjnHPGQ0iAnCyg==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -5337,6 +5346,16 @@ "node": ">=0.10.0" } }, + "node_modules/ast-metadata-inferer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/ast-metadata-inferer/-/ast-metadata-inferer-0.8.0.tgz", + "integrity": "sha512-jOMKcHht9LxYIEQu+RVd22vtgrPaVCtDRQ/16IGmurdzxvYbDd5ynxjnyrzLnieG96eTcAyaoj/wN/4/1FyyeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mdn/browser-compat-data": "^5.2.34" + } + }, "node_modules/astral-regex": { "version": "2.0.0", "dev": true, @@ -5865,7 +5884,9 @@ } }, "node_modules/browserslist": { - "version": "4.23.0", + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", "dev": true, "funding": [ { @@ -5883,10 +5904,10 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001587", - "electron-to-chromium": "^1.4.668", - "node-releases": "^2.0.14", - "update-browserslist-db": "^1.0.13" + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", + "node-releases": "^2.0.18", + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -6037,7 +6058,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001600", + "version": "1.0.30001678", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001678.tgz", + "integrity": "sha512-RR+4U/05gNtps58PEBDZcPWTgEO2MBeoPZ96aQcjmfkBWRIDfN451fW2qyDA9/+HohLLIL5GqiMwA+IB1pWarw==", "dev": true, "funding": [ { @@ -7307,7 +7330,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.715", + "version": "1.5.52", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.52.tgz", + "integrity": "sha512-xtoijJTZ+qeucLBDNztDOuQBE1ksqjvNjvqFoST3nGC7fSpqJ+X6BdTBaY5BHG+IhWWmpc6b/KfpeuEDupEPOQ==", "dev": true, "license": "ISC" }, @@ -7589,7 +7614,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "license": "MIT", "engines": { @@ -7669,6 +7696,107 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-plugin-compat": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-compat/-/eslint-plugin-compat-6.0.1.tgz", + "integrity": "sha512-0MeIEuoy8kWkOhW38kK8hU4vkb6l/VvyjpuYDymYOXmUY9NvTgyErF16lYuX+HPS5hkmym7lfA+XpYZiWYWmYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mdn/browser-compat-data": "^5.5.35", + "ast-metadata-inferer": "^0.8.0", + "browserslist": "^4.23.1", + "caniuse-lite": "^1.0.30001639", + "find-up": "^5.0.0", + "globals": "^15.7.0", + "lodash.memoize": "^4.1.2", + "semver": "^7.6.2" + }, + "engines": { + "node": ">=18.x" + }, + "peerDependencies": { + "eslint": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-compat/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-compat/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-compat/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-compat/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-compat/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-plugin-jest": { "version": "28.5.0", "dev": true, @@ -8785,7 +8913,9 @@ } }, "node_modules/globals": { - "version": "15.1.0", + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, "license": "MIT", "engines": { @@ -12125,7 +12255,9 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.14", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true, "license": "MIT" }, @@ -12638,7 +12770,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.0", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true, "license": "ISC" }, @@ -12689,7 +12823,9 @@ } }, "node_modules/postcss": { - "version": "8.4.38", + "version": "8.4.47", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", + "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", "dev": true, "funding": [ { @@ -12708,8 +12844,8 @@ "license": "MIT", "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.0", - "source-map-js": "^1.2.0" + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -14446,7 +14582,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -14655,7 +14793,9 @@ } }, "node_modules/stream-shift": { - "version": "1.0.1", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", "dev": true, "license": "MIT" }, @@ -16000,7 +16140,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.13", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", "dev": true, "funding": [ { @@ -16018,8 +16160,8 @@ ], "license": "MIT", "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.2.0", + "picocolors": "^1.1.0" }, "bin": { "update-browserslist-db": "cli.js" diff --git a/assets/package.json b/assets/package.json index 223de6575..9ce666aa4 100644 --- a/assets/package.json +++ b/assets/package.json @@ -55,11 +55,13 @@ "@types/react-router-dom": "^5.1.8", "@types/webpack-env": "^1.18.4", "babel-loader": "^8.2.2", + "browserslist": "^4.24.2", "concurrently": "^8.2.2", "copy-webpack-plugin": "^6.4.1", "css-loader": "^5.2.7", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-compat": "^6.0.1", "eslint-plugin-jest": "^28.5.0", "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.2", diff --git a/assets/webpack.config.js b/assets/webpack.config.js index f2c7f6da2..4b3b2daa1 100644 --- a/assets/webpack.config.js +++ b/assets/webpack.config.js @@ -83,15 +83,6 @@ function getCommonRules(isOfmPackage) { ]; } -const common_babel_loader_plugins = [ - "@babel/plugin-proposal-export-default-from", - "@babel/plugin-proposal-logical-assignment-operators", - ["@babel/plugin-proposal-optional-chaining", { loose: false }], - ["@babel/plugin-proposal-pipeline-operator", { proposal: "minimal" }], - ["@babel/plugin-proposal-nullish-coalescing-operator", { loose: false }], - "@babel/plugin-proposal-do-expressions", -]; - const common_plugins = [ new MiniCssExtractPlugin({ filename: "../css/[name].css" }), new CopyWebpackPlugin({ patterns: [{ from: "static/", to: "../" }] }), @@ -130,17 +121,7 @@ module.exports = (env, argv) => { { test: /\.ts(x?)$/, exclude: /node_modules/, - use: { - loader: "babel-loader", - options: { - presets: [ - ["@babel/preset-env", { targets: "> 0.25%" }], - "@babel/preset-react", - "@babel/preset-typescript", - ], - plugins: common_babel_loader_plugins, - }, - }, + use: { loader: "babel-loader" }, }, ...getCommonRules(false), ], @@ -173,7 +154,6 @@ module.exports = (env, argv) => { "@babel/preset-react", "@babel/preset-typescript", ], - plugins: common_babel_loader_plugins, }, }, },