Skip to content

Commit

Permalink
chore: Enable import/export rule (#16843)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu authored Sep 26, 2024
1 parent e02d9ef commit ea5fcb8
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 129 deletions.
37 changes: 37 additions & 0 deletions .yarn/patches/eslint-plugin-import-npm-2.30.0-4fd74d3ee6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/lib/rules/export.js b/lib/rules/export.js
index a155254c8e4c00816ef0cb128ab8c8b6d60be838..8baf0fbd492ad5d34b6e2932afe78bced223cdbc 100644
--- a/lib/rules/export.js
+++ b/lib/rules/export.js
@@ -39,17 +39,21 @@ var tsTypePrefix = 'type:';
function isTypescriptFunctionOverloads(nodes) {
var nodesArr = Array.from(nodes);

- var idents = (0, _arrayPrototype2['default'])(
- nodesArr,
- function (node) {return node.declaration && (
- node.declaration.type === 'TSDeclareFunction' // eslint 6+
- || node.declaration.type === 'TSEmptyBodyFunctionDeclaration' // eslint 4-5
- ) ?
- node.declaration.id.name :
- [];});
-
- if (new Set(idents).size !== idents.length) {
- return true;
+ if (nodesArr[0].type === "ExportDefaultDeclaration") {
+ let num = 0;
+ for (const node of nodesArr) {
+ if (
+ // eslint 6+
+ node.declaration.type === 'TSDeclareFunction' ||
+ // eslint 4-5
+ node.declaration.type === 'TSEmptyBodyFunctionDeclaration'
+ ) {
+ num++;
+ }
+ }
+ if (num === nodesArr.length - 1) {
+ return true;
+ }
}

var types = new Set(nodesArr.map(function (node) {return node.parent.type;}));
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default [
rules: {
"n/no-process-exit": "error",
"import/no-extraneous-dependencies": "error",
"import/export": "error",
"regexp/match-any": ["error", { allows: ["[^]", "dotAll"] }],
"unicorn/prefer-set-has": "error",
"unicorn/no-typeof-undefined": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-formatter-codeframe": "^7.32.1",
"eslint-import-resolver-node": "^0.3.9",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import": "patch:eslint-plugin-import@npm%3A2.30.0#~/.yarn/patches/eslint-plugin-import-npm-2.30.0-4fd74d3ee6.patch",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-regexp": "^2.6.0",
Expand Down
1 change: 1 addition & 0 deletions packages/babel-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { default as createUnionTypeAnnotation } from "./builders/flow/createFlow
export { default as createFlowUnionType } from "./builders/flow/createFlowUnionType.ts";
export { default as createTSUnionType } from "./builders/typescript/createTSUnionType.ts";
export * from "./builders/generated/index.ts";
// eslint-disable-next-line import/export
export * from "./builders/generated/uppercase.js";
export * from "./builders/productions.ts";

Expand Down
Loading

0 comments on commit ea5fcb8

Please sign in to comment.