Skip to content

Commit

Permalink
Ignore export type * (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed May 2, 2023
1 parent add5efb commit 35cfa85
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 165 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
@@ -1,12 +1,16 @@
# Changelog

## Unreleased

- Ignore `export type *` (fixes #12)

## 0.4.0

### Add `allowConstantExport` option (fixes #8)

This option allow tp don't warn when a constant (string, number, boolean, templateLiteral) is exported aside one or more components.
This option allow to don't warn when a constant (string, number, boolean, templateLiteral) is exported aside one or more components.

This should be enabled if the fast refresh implementation correctly handles this case (HMR when the constant doesn't change, propagate update to importers when the constant changes.). Vite supports it, PR welcome if you notice other integrations works well.
This should be enabled if the fast refresh implementation correctly handles this case (HMR when the constant doesn't change, propagate update to importers when the constant changes). Vite supports it, PR welcome if you notice other integrations works well.

### Allow all-uppercase function exports (fixes #11)

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,6 @@
"build": "scripts/bundle.ts",
"prettier": "bun prettier-ci --write",
"prettier-ci": "prettier --ignore-path=.gitignore --check '**/*.{ts,json,md,yml}'",
"test": "src/tests.ts",
"ci": "tsc && bun prettier-ci && bun test && bun run build"
},
"prettier": {
Expand All @@ -19,6 +18,7 @@
"@nabla/tnode": "^0.9.0",
"@types/eslint": "^8.37.0",
"@types/node": "^18.16.3",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/utils": "^5.59.1",
"bun-types": "^0.5.8",
"eslint": "^8.39.0",
Expand Down
8 changes: 7 additions & 1 deletion src/only-export-components.test.ts
Expand Up @@ -4,9 +4,10 @@ import { RuleTester } from "eslint";
import { onlyExportComponents } from "./only-export-components.ts";

const ruleTester = new RuleTester({
parser: require.resolve("@typescript-eslint/parser"),
parserOptions: {
sourceType: "module",
ecmaVersion: 2018,
ecmaVersion: 2022,
ecmaFeatures: { jsx: true },
},
});
Expand Down Expand Up @@ -76,6 +77,11 @@ const valid = [
name: "Direct export default AF",
code: "export default function foo () {};",
},
{
name: "export type *",
code: "export type * from './module';",
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
Expand Up @@ -132,6 +132,7 @@ export const onlyExportComponents: TSESLint.RuleModule<

for (const node of program.body) {
if (node.type === "ExportAllDeclaration") {
if (node.exportKind === "type") continue;
hasExports = true;
context.report({ messageId: "exportAll", node });
} else if (node.type === "ExportDefaultDeclaration") {
Expand Down

0 comments on commit 35cfa85

Please sign in to comment.