Skip to content

Commit 9e633e1

Browse files
authoredMar 20, 2025··
Merge pull request #238 from RightCapitalHQ/feature/update-deprecated-eslint-react-rules
feat: update deprecated `no-useless-custom-hooks` rule name from `@eslint-react/eslint-plugin`

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"comment": "feat: update deprecated `no-useless-custom-hooks` rule name from `@eslint-react/eslint-plugin`",
3+
"type": "patch",
4+
"packageName": "@rightcapital/eslint-config",
5+
"email": "im@pyonpyon.today",
6+
"dependentChangeType": "patch"
7+
}

‎packages/eslint-config/src/config/mixin/react.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const config: TSESLint.FlatConfig.ConfigArray = [
6161
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 'off',
6262

6363
// MEMO: Too opinionated thus we disable it
64-
'@eslint-react/hooks-extra/no-useless-custom-hooks': 'off',
64+
'@eslint-react/hooks-extra/no-unnecessary-use-prefix': 'off',
6565

6666
// A11y
6767
// Enforce that all elements that require alternative text have meaningful information

‎specs/eslint-configs/__snapshots__/presets.test.mts.snap

+4-7
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ exports[`Resolved config matches snapshot > typescript.ts 2`] = `
21472147
"simple-import-sort:eslint-plugin-simple-import-sort@12.1.1",
21482148
"@stylistic",
21492149
"@typescript-eslint:@typescript-eslint/eslint-plugin@8.26.1",
2150-
"@rightcapital:@rightcapital/eslint-plugin@42.1.0",
2150+
"@rightcapital:@rightcapital/eslint-plugin",
21512151
- "unused-imports:unused-imports",
21522152
],
21532153
"rules": Object {
@@ -3379,9 +3379,6 @@ exports[`Resolved config matches snapshot > typescript-react.tsx 1`] = `
33793379
0,
33803380
],
33813381
"@eslint-react/hooks-extra/no-unnecessary-use-prefix": [
3382-
1,
3383-
],
3384-
"@eslint-react/hooks-extra/no-useless-custom-hooks": [
33853382
0,
33863383
],
33873384
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": [
@@ -4930,14 +4927,14 @@ exports[`Resolved config matches snapshot > typescript-react.tsx 2`] = `
49304927
"simple-import-sort:eslint-plugin-simple-import-sort@12.1.1",
49314928
"@stylistic",
49324929
"@typescript-eslint:@typescript-eslint/eslint-plugin@8.26.1",
4933-
"@rightcapital:@rightcapital/eslint-plugin@42.1.0",
4930+
"@rightcapital:@rightcapital/eslint-plugin",
49344931
- "unused-imports:unused-imports",
49354932
"@eslint-react:eslint-plugin-react-x@1.36.1",
49364933
"@eslint-react/dom:eslint-plugin-react-dom@1.36.1",
49374934
"@eslint-react/web-api:eslint-plugin-react-web-api@1.36.1",
49384935
"@eslint-react/debug:eslint-plugin-react-debug@1.36.1",
49394936
"@eslint-react/hooks-extra:eslint-plugin-react-hooks-extra@1.36.1",
4940-
@@ -1558,11 +1557,11 @@
4937+
@@ -1555,11 +1554,11 @@
49414938
],
49424939
"@typescript-eslint/no-unused-expressions": Array [
49434940
2,
@@ -4950,7 +4947,7 @@ exports[`Resolved config matches snapshot > typescript-react.tsx 2`] = `
49504947
},
49514948
],
49524949
"@typescript-eslint/no-use-before-define": Array [
4953-
@@ -2682,13 +2681,10 @@
4950+
@@ -2679,13 +2678,10 @@
49544951
],
49554952
"unicorn/prefer-node-protocol": Array [
49564953
2,

‎specs/eslint-configs/presets.test.mts

+26-5
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ const parsedConfigs = await getParsedConfig();
6060
describe('Resolved config matches snapshot', () => {
6161
for (const [file, config, editorModeConfig] of parsedConfigs) {
6262
test(file, () => {
63-
expect({
64-
...config,
65-
63+
const trimConfigForSnapshot = (rawConfig) => ({
64+
...rawConfig,
6665
// These fields contain unnecessary information for snapshot
6766
parser: '<OMITTED>',
6867
plugins: '<OMITTED>',
@@ -71,10 +70,32 @@ describe('Resolved config matches snapshot', () => {
7170
...config.languageOptions,
7271
parser: '<OMITTED>',
7372
},
74-
}).toMatchSnapshot();
73+
});
74+
expect(trimConfigForSnapshot(config)).toMatchSnapshot();
7575

76+
const trimConfigForDiff = (rawConfig) => ({
77+
...rawConfig,
78+
// These fields contain unnecessary information for diff
79+
plugins: rawConfig.plugins.map((pluginName) =>
80+
pluginName.replace(
81+
/**
82+
* We have to strip the version part of our plugin name (the plugin is in this monorepo)
83+
*
84+
* from: "@rightcapital:@rightcapital/eslint-plugin@42.1.0"
85+
* to: "@rightcapital:@rightcapital/eslint-plugin"
86+
*
87+
* Since every time we publish a new version:
88+
* 1. snapshot references to existing old version of @rightcapital/eslint-plugin
89+
* 2. new version of @rightcapital/eslint-plugin published
90+
* 3. new snapshot test will reference to the new version, test fails
91+
*/
92+
/(?<=@rightcapital\/eslint-plugin)@.*$/,
93+
'',
94+
),
95+
),
96+
});
7697
expect(
77-
diff(config, editorModeConfig, {
98+
diff(trimConfigForDiff(config), trimConfigForDiff(editorModeConfig), {
7899
aAnnotation: 'Editor mode: false',
79100
bAnnotation: 'Editor mode: true',
80101
expand: false,

0 commit comments

Comments
 (0)
Please sign in to comment.