eslint-plugin-export-component 0.0.0-alpha.0 → 0.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +90 -0
- package/package.json +72 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/rules/inline-default-export-function.ts
|
|
34
|
+
var require_inline_default_export_function = __commonJS({
|
|
35
|
+
"src/rules/inline-default-export-function.ts"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var rule = {
|
|
38
|
+
meta: {
|
|
39
|
+
fixable: "code",
|
|
40
|
+
type: "problem"
|
|
41
|
+
},
|
|
42
|
+
create: (context) => ({
|
|
43
|
+
ExportDefaultDeclaration: (node) => {
|
|
44
|
+
if (node.declaration.type !== "Identifier")
|
|
45
|
+
return;
|
|
46
|
+
const ExportDefaultFunctionName = node.declaration.name;
|
|
47
|
+
if (!/^[A-Z]/.test(ExportDefaultFunctionName))
|
|
48
|
+
return;
|
|
49
|
+
const program = context.sourceCode.ast;
|
|
50
|
+
const targetNode = program.body.find(
|
|
51
|
+
(n) => n.type === "FunctionDeclaration" && n.id?.name === ExportDefaultFunctionName
|
|
52
|
+
);
|
|
53
|
+
const [targetNodeStart, targetNodeEnd] = targetNode?.range ?? [
|
|
54
|
+
void 0,
|
|
55
|
+
void 0
|
|
56
|
+
];
|
|
57
|
+
if (!targetNodeStart || !targetNodeEnd)
|
|
58
|
+
return;
|
|
59
|
+
context.report({
|
|
60
|
+
node,
|
|
61
|
+
message: "Export should be done in the function declaration line.",
|
|
62
|
+
fix: (fixer) => [
|
|
63
|
+
fixer.insertTextBeforeRange(
|
|
64
|
+
[targetNodeStart, targetNodeEnd],
|
|
65
|
+
"export default "
|
|
66
|
+
),
|
|
67
|
+
fixer.remove(node)
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
module2.exports = rule;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// src/index.ts
|
|
78
|
+
var src_exports = {};
|
|
79
|
+
__export(src_exports, {
|
|
80
|
+
rules: () => rules
|
|
81
|
+
});
|
|
82
|
+
module.exports = __toCommonJS(src_exports);
|
|
83
|
+
var import_inline_default_export_function = __toESM(require_inline_default_export_function());
|
|
84
|
+
var rules = {
|
|
85
|
+
"inline-default-export-function": import_inline_default_export_function.default
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
rules
|
|
90
|
+
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "zorro901",
|
|
4
|
+
"url": "https://github.com/zorro901"
|
|
5
|
+
},
|
|
3
6
|
"description": "ESLint plugin for making your code easier to read",
|
|
4
|
-
"
|
|
5
|
-
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@eslint/js": "^8.50.0",
|
|
9
|
+
"@types/eslint": "8.44.3",
|
|
10
|
+
"@types/jest": "29.5.5",
|
|
11
|
+
"@typescript-eslint/eslint-plugin": "6.7.3",
|
|
12
|
+
"@typescript-eslint/parser": "6.7.3",
|
|
13
|
+
"@typescript-eslint/utils": "6.7.3",
|
|
14
|
+
"commitizen": "4.3.0",
|
|
15
|
+
"cz-conventional-changelog": "3.3.0",
|
|
16
|
+
"esbuild": "0.19.4",
|
|
17
|
+
"eslint": "8.50.0",
|
|
18
|
+
"eslint-plugin-eslint-plugin": "^5.1.1",
|
|
19
|
+
"eslint-remote-tester": "3.0.0",
|
|
20
|
+
"eslint-remote-tester-repositories": "1.0.1",
|
|
21
|
+
"husky": "8.0.3",
|
|
22
|
+
"jest": "29.7.0",
|
|
23
|
+
"lint-staged": "14.0.1",
|
|
24
|
+
"prettier": "3.0.3",
|
|
25
|
+
"semantic-release": "22.0.5",
|
|
26
|
+
"ts-jest": "29.1.1",
|
|
27
|
+
"typescript": "5.2.2"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"keywords": [
|
|
36
|
+
"lint",
|
|
37
|
+
"code-style",
|
|
38
|
+
"typescript",
|
|
39
|
+
"eslint",
|
|
40
|
+
"react",
|
|
41
|
+
"react-hooks",
|
|
42
|
+
"hooks",
|
|
43
|
+
"eslint-plugin",
|
|
44
|
+
"eslintplugin"
|
|
45
|
+
],
|
|
46
|
+
"lint-staged": {
|
|
47
|
+
"*.{ts,tsx,json,md}": "prettier --ignore-unknown --write",
|
|
48
|
+
"*.{ts,tsx}": "eslint --cache --fix"
|
|
49
|
+
},
|
|
50
|
+
"license": "Apache-2.0",
|
|
51
|
+
"main": "dist/index.js",
|
|
52
|
+
"name": "eslint-plugin-export-component",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/zorro901/eslint-plugin-export-component.git"
|
|
56
|
+
},
|
|
57
|
+
"version": "0.0.0-alpha.1",
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --external:eslint --external:@typescript-eslint/utils",
|
|
60
|
+
"build:dist": "tsc --noEmit && pnpm build -- --minify",
|
|
61
|
+
"build:watch": "pnpm build -- --watch",
|
|
62
|
+
"clean": "pnpm dlx rimraf dist",
|
|
63
|
+
"deploy:docs": "cd documentation && yarn install && USE_SSH=true yarn deploy",
|
|
64
|
+
"format:check": "prettier src --ignore-unknown --check",
|
|
65
|
+
"format:fix": "prettier src --ignore-unknown --write",
|
|
66
|
+
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
67
|
+
"lint:fix": "pnpm lint -- --fix",
|
|
68
|
+
"lint:remote": "eslint-remote-tester",
|
|
69
|
+
"semantic-release": "semantic-release",
|
|
70
|
+
"test": "jest",
|
|
71
|
+
"test:watch": "jest --watch",
|
|
72
|
+
"test:watch:all": "jest --watchAll"
|
|
73
|
+
}
|
|
74
|
+
}
|