Skip to content

Commit 2dadd5e

Browse files
committed
Bump deps
1 parent 91f7ebc commit 2dadd5e

File tree

9 files changed

+223
-243
lines changed

9 files changed

+223
-243
lines changed

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"typescript.tsserver.experimental.enableProjectDiagnostics": true,
4+
"typescript.updateImportsOnFileMove.enabled": "always",
5+
"typescript.preferences.useAliasesForRenames": false,
6+
7+
"[json]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[jsonc]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
13+
"[typescript]": {
14+
"editor.defaultFormatter": "esbenp.prettier-vscode"
15+
},
16+
17+
"terminal.integrated.env.osx": {
18+
"PATH": "./node_modules/.bin:${env:PATH}"
19+
}
20+
}

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,56 +33,58 @@ This plugin provides a single rule, `react-refresh/only-export-components`. Ther
3333
### Recommended config
3434

3535
```js
36+
import { defineConfig } from "eslint/config";
3637
import reactRefresh from "eslint-plugin-react-refresh";
3738

38-
export default [
39+
export default defineConfig(
3940
/* Main config */
4041
reactRefresh.configs.recommended,
41-
];
42+
);
4243
```
4344

4445
### Vite config
4546

4647
This enables the `allowConstantExport` option which is supported by Vite React plugins.
4748

4849
```js
50+
import { defineConfig } from "eslint/config";
4951
import reactRefresh from "eslint-plugin-react-refresh";
5052

51-
export default [
53+
export default defineConfig(
5254
/* Main config */
5355
reactRefresh.configs.vite,
54-
];
56+
);
5557
```
5658

57-
### Next config
59+
### Next config <small>(v0.4.21)</small>
5860

5961
This allows exports like `fetchCache` and `revalidate` which are used in Page or Layout components and don't trigger a full page reload.
6062

6163
```js
64+
import { defineConfig } from "eslint/config";
6265
import reactRefresh from "eslint-plugin-react-refresh";
6366

64-
export default [
67+
export default defineConfig(
6568
/* Main config */
6669
reactRefresh.configs.next,
67-
];
70+
);
6871
```
6972

7073
### Without config
7174

7275
```js
76+
import { defineConfig } from "eslint/config";
7377
import reactRefresh from "eslint-plugin-react-refresh";
7478

75-
export default [
76-
{
77-
// in main config for TSX/JSX source files
78-
plugins: {
79-
"react-refresh": reactRefresh,
80-
},
81-
rules: {
82-
"react-refresh/only-export-components": "error",
83-
},
79+
export default defineConfig({
80+
// in main config for TSX/JSX source files
81+
plugins: {
82+
"react-refresh": reactRefresh,
8483
},
85-
];
84+
rules: {
85+
"react-refresh/only-export-components": "error",
86+
},
87+
});
8688
```
8789

8890
### Legacy config
@@ -91,8 +93,8 @@ export default [
9193
{
9294
"plugins": ["react-refresh"],
9395
"rules": {
94-
"react-refresh/only-export-components": "error"
95-
}
96+
"react-refresh/only-export-components": "error",
97+
},
9698
}
9799
```
98100

bun.lock

Lines changed: 105 additions & 154 deletions
Large diffs are not rendered by default.

eslint.config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import baseConfig from "@arnaud-barre/eslint-config";
2+
import { defineConfig } from "eslint/config";
23

3-
export default [
4-
...baseConfig,
5-
{
6-
rules: {
7-
"@arnaud-barre/no-default-export": "off",
8-
},
4+
export default defineConfig(baseConfig, {
5+
rules: {
6+
"@arnaud-barre/no-default-export": "off",
97
},
10-
];
8+
});

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
"lint": "eslint --max-warnings 0",
1010
"prettier": "bun prettier-ci --write",
1111
"prettier-ci": "prettier --ignore-path=.gitignore --check '**/*.{js,ts,json,md,yml}'",
12-
"ci": "tsc && bun lint && bun prettier-ci && bun test && bun run build && cd dist && publint"
12+
"ci": "tsl && bun lint && bun prettier-ci && bun test && bun run build && cd dist && publint"
13+
},
14+
"prettier": {
15+
"experimentalOperatorPosition": "start"
1316
},
14-
"prettier": {},
1517
"peerDependencies": {
1618
"eslint": ">=8.40"
1719
},
1820
"devDependencies": {
19-
"@arnaud-barre/eslint-config": "^5.2.4",
20-
"@arnaud-barre/tnode": "^0.24.0",
21-
"@types/eslint": "^9.6.1",
22-
"@types/node": "^20.17.30",
23-
"@typescript-eslint/parser": "^8.30.1",
24-
"@typescript-eslint/utils": "^8.30.1",
25-
"bun-types": "^1.2.10",
26-
"eslint": "^9.25.0",
27-
"prettier": "3.0.3",
28-
"publint": "^0.3.12",
29-
"typescript": "~5.8"
21+
"@arnaud-barre/eslint-config": "^6.1.2",
22+
"@arnaud-barre/tsl-config": "^0.1.1",
23+
"@typescript-eslint/parser": "^8.44.1",
24+
"@typescript-eslint/utils": "^8.44.1",
25+
"bun-types": "^1.2.22",
26+
"eslint": "^9.36.0",
27+
"prettier": "^3.6.2",
28+
"publint": "^0.3.13",
29+
"tsl": "^1.0.25",
30+
"typescript": "~5.9"
3031
}
3132
}

scripts/bundle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env tnode
1+
#!/usr/bin/env node
22
import { rmSync, writeFileSync } from "node:fs";
33
import { execSync } from "node:child_process";
44
import { build } from "esbuild";
55

6-
import packageJSON from "../package.json";
6+
import packageJSON from "../package.json" with { type: "json" };
77

88
rmSync("dist", { force: true, recursive: true });
99

src/only-export-components.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ export const onlyExportComponents: TSESLint.RuleModule<
6060
const filename = context.filename;
6161
// Skip tests & stories files
6262
if (
63-
filename.includes(".test.") ||
64-
filename.includes(".spec.") ||
65-
filename.includes(".cy.") ||
66-
filename.includes(".stories.")
63+
filename.includes(".test.")
64+
|| filename.includes(".spec.")
65+
|| filename.includes(".cy.")
66+
|| filename.includes(".stories.")
6767
) {
6868
return {};
6969
}
7070
const shouldScan =
71-
filename.endsWith(".jsx") ||
72-
filename.endsWith(".tsx") ||
73-
(checkJS && filename.endsWith(".js"));
71+
filename.endsWith(".jsx")
72+
|| filename.endsWith(".tsx")
73+
|| (checkJS && filename.endsWith(".js"));
7474
if (!shouldScan) return {};
7575

7676
const allowExportNamesSet = allowExportNames
@@ -83,8 +83,8 @@ export const onlyExportComponents: TSESLint.RuleModule<
8383
const jsInit = skipTSWrapper(init);
8484
if (jsInit.type === "ArrowFunctionExpression") return true;
8585
if (
86-
jsInit.type === "CallExpression" &&
87-
jsInit.callee.type === "Identifier"
86+
jsInit.type === "CallExpression"
87+
&& jsInit.callee.type === "Identifier"
8888
) {
8989
return reactHOCs.includes(jsInit.callee.name);
9090
}
@@ -114,9 +114,9 @@ export const onlyExportComponents: TSESLint.RuleModule<
114114
}
115115
if (allowExportNamesSet?.has(identifierNode.name)) return;
116116
if (
117-
allowConstantExport &&
118-
init &&
119-
constantExportExpressions.has(skipTSWrapper(init).type)
117+
allowConstantExport
118+
&& init
119+
&& constantExportExpressions.has(skipTSWrapper(init).type)
120120
) {
121121
return;
122122
}
@@ -129,22 +129,22 @@ export const onlyExportComponents: TSESLint.RuleModule<
129129
}
130130
} else {
131131
if (
132-
init &&
133-
init.type === "CallExpression" &&
132+
init
133+
&& init.type === "CallExpression"
134134
// createContext || React.createContext
135-
((init.callee.type === "Identifier" &&
136-
init.callee.name === "createContext") ||
137-
(init.callee.type === "MemberExpression" &&
138-
init.callee.property.type === "Identifier" &&
139-
init.callee.property.name === "createContext"))
135+
&& ((init.callee.type === "Identifier"
136+
&& init.callee.name === "createContext")
137+
|| (init.callee.type === "MemberExpression"
138+
&& init.callee.property.type === "Identifier"
139+
&& init.callee.property.name === "createContext"))
140140
) {
141141
reactContextExports.push(identifierNode);
142142
return;
143143
}
144144
if (
145-
init &&
145+
init
146146
// Switch to allowList?
147-
notReactComponentExpression.has(init.type)
147+
&& notReactComponentExpression.has(init.type)
148148
) {
149149
nonComponentExports.push(identifierNode);
150150
return;
@@ -163,16 +163,16 @@ export const onlyExportComponents: TSESLint.RuleModule<
163163
const isCalleeHOC =
164164
// support for react-redux
165165
// export default connect(mapStateToProps, mapDispatchToProps)(...)
166-
(node.callee.type === "CallExpression" &&
167-
node.callee.callee.type === "Identifier" &&
168-
node.callee.callee.name === "connect") ||
166+
(node.callee.type === "CallExpression"
167+
&& node.callee.callee.type === "Identifier"
168+
&& node.callee.callee.name === "connect")
169169
// React.memo(...)
170-
(node.callee.type === "MemberExpression" &&
171-
node.callee.property.type === "Identifier" &&
172-
reactHOCs.includes(node.callee.property.name)) ||
170+
|| (node.callee.type === "MemberExpression"
171+
&& node.callee.property.type === "Identifier"
172+
&& reactHOCs.includes(node.callee.property.name))
173173
// memo(...)
174-
(node.callee.type === "Identifier" &&
175-
reactHOCs.includes(node.callee.name));
174+
|| (node.callee.type === "Identifier"
175+
&& reactHOCs.includes(node.callee.name));
176176
if (!isCalleeHOC) return false;
177177
if (node.arguments.length === 0) return false;
178178
const arg = skipTSWrapper(node.arguments[0]);
@@ -229,9 +229,9 @@ export const onlyExportComponents: TSESLint.RuleModule<
229229
hasExports = true;
230230
const declaration = skipTSWrapper(node.declaration);
231231
if (
232-
declaration.type === "VariableDeclaration" ||
233-
declaration.type === "FunctionDeclaration" ||
234-
declaration.type === "CallExpression"
232+
declaration.type === "VariableDeclaration"
233+
|| declaration.type === "FunctionDeclaration"
234+
|| declaration.type === "CallExpression"
235235
) {
236236
handleExportDeclaration(declaration);
237237
}
@@ -249,18 +249,18 @@ export const onlyExportComponents: TSESLint.RuleModule<
249249
}
250250
for (const specifier of node.specifiers) {
251251
handleExportIdentifier(
252-
specifier.exported.type === "Identifier" &&
253-
specifier.exported.name === "default"
252+
specifier.exported.type === "Identifier"
253+
&& specifier.exported.name === "default"
254254
? specifier.local
255255
: specifier.exported,
256256
);
257257
}
258258
} else if (node.type === "VariableDeclaration") {
259259
for (const variable of node.declarations) {
260260
if (
261-
variable.id.type === "Identifier" &&
262-
reactComponentNameRE.test(variable.id.name) &&
263-
canBeReactFunctionComponent(variable.init)
261+
variable.id.type === "Identifier"
262+
&& reactComponentNameRE.test(variable.id.name)
263+
&& canBeReactFunctionComponent(variable.init)
264264
) {
265265
localComponents.push(variable.id);
266266
}
@@ -270,8 +270,8 @@ export const onlyExportComponents: TSESLint.RuleModule<
270270
localComponents.push(node.id);
271271
}
272272
} else if (
273-
node.type === "ImportDeclaration" &&
274-
node.source.value === "react"
273+
node.type === "ImportDeclaration"
274+
&& node.source.value === "react"
275275
) {
276276
reactIsInScope = true;
277277
}
@@ -280,7 +280,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
280280
if (checkJS && !reactIsInScope) return;
281281

282282
if (hasExports) {
283-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
283+
// tsl-ignore core/noUnnecessaryCondition
284284
if (hasReactExport) {
285285
for (const node of nonComponentExports) {
286286
context.report({ messageId: "namedExport", node });

tsconfig.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
{
2-
"include": ["src", "scripts"],
2+
"include": ["**/*.ts"],
33
"compilerOptions": {
44
"target": "ES2020",
55
"module": "ESNext",
6+
"moduleDetection": "force",
67
"lib": ["ES2020"],
7-
"types": ["bun-types"],
8+
"types": ["bun-types", "tsl/patches"],
9+
"skipLibCheck": true,
810

9-
/* esbuild compilation */
11+
/* Bundler mode */
1012
"moduleResolution": "bundler",
1113
"allowImportingTsExtensions": true,
12-
"resolveJsonModule": true,
1314
"verbatimModuleSyntax": true,
15+
"erasableSyntaxOnly": true,
1416
"noEmit": true,
1517

1618
/* Linting */
17-
"skipLibCheck": true,
1819
"strict": true,
19-
"noUnusedLocals": true,
20-
"noUnusedParameters": true,
2120
"noFallthroughCasesInSwitch": true,
2221
"useUnknownInCatchVariables": true,
23-
"noPropertyAccessFromIndexSignature": true
22+
"noUncheckedSideEffectImports": true,
23+
"noPropertyAccessFromIndexSignature": true,
24+
25+
"plugins": [{ "name": "tsl/plugin" }]
2426
}
2527
}

tsl.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { allRules } from "@arnaud-barre/tsl-config";
2+
import { defineConfig } from "tsl";
3+
4+
export default defineConfig({
5+
rules: [...allRules],
6+
});

0 commit comments

Comments
 (0)