Skip to content

Commit

Permalink
Ignore type exports (ex. export type foo = string;) (fixes #47) [pu…
Browse files Browse the repository at this point in the history
…blish]
  • Loading branch information
ArnaudBarre committed Aug 22, 2024
1 parent 7101b09 commit d327c35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.4.11

- Ignore type exports (ex. `export type foo = string;`) (fixes #47)

## 0.4.10

- Support `function Foo() {}; export default React.memo(Foo)` (#46) (thanks @SukkaW!)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "eslint-plugin-react-refresh",
"version": "0.4.10",
"version": "0.4.11",
"type": "module",
"license": "MIT",
"scripts": {
"build": "scripts/bundle.ts",
"test": "bun test",
"lint": "bun lint-ci --fix --cache",
"lint-ci": "eslint ./ --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"prettier": "bun prettier-ci --write",
Expand Down
10 changes: 10 additions & 0 deletions src/only-export-components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ const valid = [
code: "export type * from './module';",
filename: "Test.tsx",
},
{
name: "export type { foo }",
code: "type foo = string; export const Foo = () => null; export type { foo };",
filename: "Test.tsx",
},
{
name: "export type foo",
code: "export type foo = string; export const Foo = () => null;",
filename: "Test.tsx",
},
{
name: "Mixed export in JS without checkJS",
code: "export const foo = () => {}; export const Bar = () => {};",
Expand Down
1 change: 1 addition & 0 deletions src/only-export-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
context.report({ messageId: "anonymousExport", node });
}
} else if (node.type === "ExportNamedDeclaration") {
if (node.exportKind === "type") continue;
hasExports = true;
if (node.declaration) handleExportDeclaration(node.declaration);
for (const specifier of node.specifiers) {
Expand Down

0 comments on commit d327c35

Please sign in to comment.