Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update eslint (major) #3394

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/eleven-apples-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rnx-kit/eslint-plugin": patch
---

Bumped `eslint-plugin-react` and `eslint-plugin-react-hooks` to better support
ESLint 9.x
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-native": "^0.75.0",
Expand Down
2 changes: 1 addition & 1 deletion incubator/@react-native-webapis/web-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@rnx-kit/eslint-config": "*",
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion incubator/build-plugin-firebase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@rnx-kit/eslint-config": "*",
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion incubator/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@types/node": "^20.0.0",
"@types/qrcode": "^1.4.2",
"@types/yargs": "^16.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion incubator/commitlint-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion incubator/esbuild-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"@types/yargs": "^16.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion incubator/patcher-rnmacos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/fs-extra": "^9.0.0",
"@types/istextorbinary": "^2.3.0",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
1 change: 0 additions & 1 deletion incubator/patcher-rnmacos/src/patch/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ function applyPatch(

for (const hunk of hunks) {
let fuzzingOffset = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
const modifications = evaluateHunk(hunk, fileLines, fuzzingOffset);
if (modifications) {
Expand Down
2 changes: 1 addition & 1 deletion incubator/polyfills/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/babel__helper-plugin-utils": "^7.0.0",
"@types/babel__template": "^7.0.0",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"metro-config": "^0.80.3",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"@types/yargs": "^16.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion incubator/rn-changelog-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@types/node": "^20.0.0",
"chalk": "^4.1.0",
"deepmerge": "^4.2.2",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"fast-levenshtein": "^3.0.0",
"jest": "^29.2.1",
"p-limit": "^3.1.0",
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@changesets/cli": "^2.22.0",
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"knip": "^5.30.2",
"metro": "^0.80.3",
"nx": "~19.5.0",
Expand All @@ -51,7 +51,7 @@
},
"packageManager": "[email protected]",
"resolutions": {
"@microsoft/eslint-plugin-sdl/eslint-plugin-react": "^7.33.0",
"@microsoft/eslint-plugin-sdl/eslint-plugin-react": "^7.35.2",
"@microsoft/eslint-plugin-sdl/eslint-plugin-security": "^1.4.0",
"@react-native-community/cli": "^14.0.0",
"@react-native-community/cli-platform-android": "^14.0.0",
Expand Down Expand Up @@ -148,9 +148,6 @@
},
"packages/eslint-plugin": {
"ignoreDependencies": [
"@microsoft/eslint-plugin-sdl",
"eslint-plugin-node",
"eslint-plugin-react",
"eslint-plugin-react-hooks"
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/align-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@types/semver": "^7.0.0",
"@types/yargs": "^16.0.0",
"detect-indent": "^6.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"markdown-table": "^3.0.0",
"package-json": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-import-path-remapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/babel__core": "^7.0.0",
"@types/babel__helper-plugin-utils": "^7.0.0",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-metro-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@types/babel__core": "^7.0.0",
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "^0.76.5",
"prettier": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"@types/qrcode": "^1.4.2",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"markdown-table": "^3.0.0",
"metro": "^0.80.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"@types/semver": "^7.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"metro": "^0.80.3",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@rnx-kit/tsconfig": "*",
"@types/node": "^20.0.0",
"esbuild": "^0.23.0",
"eslint": "^8.56.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
22 changes: 12 additions & 10 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");
const sdl = require("@microsoft/eslint-plugin-sdl");
const rnx = require("@rnx-kit/eslint-plugin");

const compat = new FlatCompat({
// Use `@rnx-kit/eslint-plugin` as base directory to ensure we get the same
// plugin instances
baseDirectory: require.resolve("@rnx-kit/eslint-plugin/package.json"),
recommendedConfig: js.configs.recommended,
});

/**
* Note that we don't directly use `sdl.configs.required` because:
*
* 1. It includes rules for Angular and Electron
* 2. Its `react` preset conflicts with our direct use of `eslint-plugin-react`
*
* https://github.com/microsoft/eslint-plugin-sdl/blob/957996315c80fdadcd1a9f7bb76fc4663d33ef1e/lib/index.js#L47-L54
*/
module.exports = [
...sdl.configs.common,
...sdl.configs.node,
...rnx.configs.strict,
...rnx.configs.stylistic,
...compat.extends("plugin:@microsoft/sdl/required"),
{
rules: {
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
...sdl.configs.react[0].rules,
},
},
];
6 changes: 3 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"format": "prettier --write --log-level error README.md index.js package.json"
},
"dependencies": {
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "^8.56.0",
"@microsoft/eslint-plugin-sdl": "^1.0.0",
"@rnx-kit/eslint-plugin": "workspace:*"
},
"peerDependencies": {
"eslint": ">=8.56.0"
"eslint": "^9.0.0"
},
"devDependencies": {
"eslint": "^9.0.0",
"prettier": "^3.0.0"
},
"engines": {
Expand Down
12 changes: 5 additions & 7 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,30 @@
"test": "rnx-kit-scripts test"
},
"dependencies": {
"@eslint/eslintrc": "^2.1.4",
"@eslint/eslintrc": "^3.0.0",
"@react-native/eslint-plugin": "^0.75.0",
"enhanced-resolve": "^5.8.3",
"eslint-plugin-react": "^7.33.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.35.2",
"eslint-plugin-react-hooks": "^5.0.0",
"typescript-eslint": "^8.0.0"
},
"peerDependencies": {
"eslint": ">=8.57.0"
},
"devDependencies": {
"@microsoft/eslint-plugin-sdl": "^0.2.0",
"@rnx-kit/eslint-config": "*",
"@rnx-kit/jest-preset": "*",
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@types/eslint": "^8.0.0",
"@types/eslint": "^9.0.0",
"@types/eslint__eslintrc": "^2.1.1",
"@types/eslint__js": "^8.0.0",
"@types/estree": "*",
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@typescript-eslint/types": "^8.0.0",
"eslint": "^8.56.0",
"eslint-plugin-node": "11.1.0",
"eslint": "^9.0.0",
"jest": "^29.2.1",
"prettier": "^3.0.0",
"typescript": "^5.0.0"
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/src/configs/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-check
"use strict";

const path = require("node:path");

try {
const eslint = path.dirname(require.resolve("eslint/package.json"));
const eslintjs = require.resolve("@eslint/js", { paths: [eslint] });
module.exports = require(eslintjs);
} catch (_) {
module.exports = require("@eslint/js");
}
16 changes: 16 additions & 0 deletions packages/eslint-plugin/src/configs/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @ts-check
"use strict";

const { FlatCompat } = require("@eslint/eslintrc");
const react = require("eslint-plugin-react");
const eslint = require("./eslint");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: eslint.configs.recommended,
});

module.exports = [
...compat.extends("plugin:react-hooks/recommended"),
react.configs.flat.recommended,
];
23 changes: 4 additions & 19 deletions packages/eslint-plugin/src/configs/recommended.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
// @ts-check
"use strict";

const { FlatCompat } = require("@eslint/eslintrc");
const js = (() => {
const path = require("node:path");
try {
const eslint = path.dirname(require.resolve("eslint/package.json"));
const eslintjs = require.resolve("@eslint/js", { paths: [eslint] });
return require(eslintjs);
} catch (_) {
return require("@eslint/js");
}
})();
const tseslint = require("typescript-eslint");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
const eslint = require("./eslint");

/**
* @param {string} spec
Expand All @@ -32,11 +17,10 @@ function isInstalled(spec) {
}

const usesReact = isInstalled("react");
const reactConfigs = usesReact
? compat.extends("plugin:react-hooks/recommended", "plugin:react/recommended")
: [];
const reactConfigs = usesReact ? require("./react") : [];

module.exports = [
eslint.configs.recommended,
...tseslint.configs.recommended,
...reactConfigs,
{
Expand Down Expand Up @@ -68,6 +52,7 @@ module.exports = [
},
],
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off",
...(usesReact ? { "react/prop-types": "off" } : {}),
},
settings: {
Expand Down
20 changes: 10 additions & 10 deletions packages/eslint-plugin/test/RuleTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { RuleTester } from "eslint";

export function makeRuleTester() {
return new RuleTester({
env: {
es6: true,
node: true,
},
parser: require.resolve("@typescript-eslint/parser"),
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: require("@typescript-eslint/parser"),
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
});
}
Loading
Loading