Skip to content

Commit

Permalink
fixup! fix(deps): update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Oct 17, 2024
1 parent 785b90c commit a91192d
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 141 deletions.
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
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
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
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": "^3.0.0",
"@eslint/js": "^9.0.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
8 changes: 3 additions & 5 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,19 @@
"@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": "*",
Expand All @@ -68,7 +67,6 @@
"@typescript-eslint/parser": "^8.0.0",
"@typescript-eslint/types": "^8.0.0",
"eslint": "^9.0.0",
"eslint-plugin-node": "11.1.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
26 changes: 16 additions & 10 deletions packages/eslint-plugin/test/RuleTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ 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",
globals: {
console: "readonly",
module: "readonly",
process: "readonly",
require: "readonly",
},
parser: require("@typescript-eslint/parser"),
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
});
}
2 changes: 0 additions & 2 deletions packages/eslint-plugin/test/no-export-all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ describe("disallows `export *`", () => {
{
code: "export * from 'recall';",
errors: 1,
output: "export * from 'recall';",
},
{
code: "export * from 'this-package-does-not-exist';",
errors: 1,
output: "export * from 'this-package-does-not-exist';",
},
{
code: "export * from 'types';",
Expand Down
12 changes: 12 additions & 0 deletions packages/jest-preset/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ module.exports = [
},
},
],
"no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
];
2 changes: 1 addition & 1 deletion packages/metro-resolver-symlinks/src/utils/patchMetro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function patchMetro(options: Options): void {
req: { url: string },
res: unknown
): Promise<void> {
// eslint-disable-next-line node/no-deprecated-api
// eslint-disable-next-line n/no-deprecated-api
const urlObj = url.parse(decodeURI(req.url), true);
let [, assetPath] =
(urlObj &&
Expand Down
2 changes: 1 addition & 1 deletion scripts/align-deps-preset.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const profile = {
},
eslint: {
name: "eslint",
version: "^8.56.0",
version: "^9.0.0",
devOnly: true,
},
"find-up": {
Expand Down
Loading

0 comments on commit a91192d

Please sign in to comment.