eslint-plugin-export-component 0.0.0-alpha.1 → 0.0.0-alpha.3

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/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # eslint-plugin-export-component
2
+
3
+ ESLint plugin that moves `export default` onto the function declaration line.
4
+
5
+ ```ts
6
+ // before
7
+ function Example() {}
8
+ export default Example
9
+
10
+ // after (auto-fixable)
11
+ export default function Example() {}
12
+ ```
13
+
14
+ Only functions whose name starts with an uppercase letter (components) are reported.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ npm i -D eslint eslint-plugin-export-component
20
+ ```
21
+
22
+ Requires ESLint 9+ (flat config).
23
+
24
+ ## Usage
25
+
26
+ ```js
27
+ // eslint.config.js
28
+ import { configs } from 'eslint-plugin-export-component'
29
+
30
+ export default [configs.recommended]
31
+ ```
32
+
33
+ ## Rules
34
+
35
+ | Rule | Fixable |
36
+ | -------------------------------- | ------- |
37
+ | `inline-default-export-function` | ✅ |
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},x=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of f(e))!d.call(t,o)&&o!==n&&l(t,o,{get:()=>e[o],enumerable:!(s=m(e,o))||s.enumerable});return t};var y=t=>x(l({},"__esModule",{value:!0}),t);var F={};g(F,{configs:()=>u,default:()=>b});module.exports=y(F);var E={meta:{fixable:"code",type:"problem",messages:{onlyExportFunction:"Export should be done in the function declaration line."},schema:[]},create:t=>({ExportDefaultDeclaration:e=>{if(e.declaration.type!=="Identifier")return;let n=e.declaration.name;if(!/^[A-Z]/.test(n))return;let p=t.sourceCode.ast.body.find(r=>r.type==="FunctionDeclaration"&&r.id?.name===n)?.range;p&&t.report({node:e,messageId:"onlyExportFunction",fix:r=>[r.insertTextBeforeRange(p,"export default "),r.remove(e)]})}})},c=E;var i=require("@typescript-eslint/parser"),a={configs:{},rules:{"inline-default-export-function":c}},u={recommended:{name:"eslint-plugin-export-component/recommended",files:["**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}"],plugins:{"eslint-plugin-export-component":a},rules:{"eslint-plugin-export-component/inline-default-export-function":"error"},languageOptions:{parser:{parse:i.parse,parseForESLint:i.parseForESLint},globals:{console:"readonly"}}}};Object.assign(a.configs,u);var b=a;0&&(module.exports={configs});
@@ -0,0 +1,8 @@
1
+ import { Linter, ESLint } from 'eslint';
2
+
3
+ declare const plugin: ESLint.Plugin;
4
+ declare const configs: {
5
+ recommended: Linter.Config;
6
+ };
7
+
8
+ export { configs, plugin as default };
@@ -0,0 +1,8 @@
1
+ import { Linter, ESLint } from 'eslint';
2
+
3
+ declare const plugin: ESLint.Plugin;
4
+ declare const configs: {
5
+ recommended: Linter.Config;
6
+ };
7
+
8
+ export { configs, plugin as default };
package/dist/index.js CHANGED
@@ -1,90 +1 @@
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
- });
1
+ var l={meta:{fixable:"code",type:"problem",messages:{onlyExportFunction:"Export should be done in the function declaration line."},schema:[]},create:o=>({ExportDefaultDeclaration:t=>{if(t.declaration.type!=="Identifier")return;let r=t.declaration.name;if(!/^[A-Z]/.test(r))return;let i=o.sourceCode.ast.body.find(e=>e.type==="FunctionDeclaration"&&e.id?.name===r)?.range;i&&o.report({node:t,messageId:"onlyExportFunction",fix:e=>[e.insertTextBeforeRange(i,"export default "),e.remove(t)]})}})},s=l;import{parse as a,parseForESLint as p}from"@typescript-eslint/parser";var n={configs:{},rules:{"inline-default-export-function":s}},c={recommended:{name:"eslint-plugin-export-component/recommended",files:["**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}"],plugins:{"eslint-plugin-export-component":n},rules:{"eslint-plugin-export-component/inline-default-export-function":"error"},languageOptions:{parser:{parse:a,parseForESLint:p},globals:{console:"readonly"}}}};Object.assign(n.configs,c);var x=n;export{c as configs,x as default};
package/package.json CHANGED
@@ -3,28 +3,41 @@
3
3
  "name": "zorro901",
4
4
  "url": "https://github.com/zorro901"
5
5
  },
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
6
20
  "description": "ESLint plugin for making your code easier to read",
7
21
  "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",
22
+ "@eslint/js": "10.0.1",
23
+ "@types/jest": "30.0.0",
24
+ "commitizen": "4.3.2",
15
25
  "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"
26
+ "eslint": "10.13.0",
27
+ "eslint-plugin-eslint-plugin": "7.6.2",
28
+ "eslint-plugin-n": "18.5.0",
29
+ "husky": "9.1.7",
30
+ "jest": "30.5.2",
31
+ "lint-staged": "17.6.0",
32
+ "prettier": "3.9.10",
33
+ "ts-jest": "29.4.15",
34
+ "ts-node": "10.9.2",
35
+ "tsup": "9.0.0",
36
+ "typescript": "6.0.2",
37
+ "typescript-eslint": "8.71.2"
38
+ },
39
+ "peerDependencies": {
40
+ "eslint": ">=9"
28
41
  },
29
42
  "engines": {
30
43
  "node": ">=18"
@@ -48,27 +61,28 @@
48
61
  "*.{ts,tsx}": "eslint --cache --fix"
49
62
  },
50
63
  "license": "Apache-2.0",
51
- "main": "dist/index.js",
52
64
  "name": "eslint-plugin-export-component",
53
65
  "repository": {
54
66
  "type": "git",
55
- "url": "https://github.com/zorro901/eslint-plugin-export-component.git"
67
+ "url": "git+https://github.com/zorro901/eslint-plugin-export-component.git"
56
68
  },
57
- "version": "0.0.0-alpha.1",
58
69
  "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
+ "build": "tsup src/lib/index.ts --format cjs,esm --dts --clean",
71
+ "build:dist": "tsc --noEmit && bun run build --minify",
72
+ "build:watch": "bun run build --watch",
73
+ "clean": "bunx rimraf dist",
74
+ "format:check": "prettier src/**/* --ignore-unknown --check",
75
+ "format:fix": "prettier src/**/* --ignore-unknown --write",
76
+ "lint": "eslint \"src/lib/**/*.{ts,tsx}\"",
77
+ "lint:fix": "bun run lint --fix",
78
+ "prepare": "husky",
70
79
  "test": "jest",
71
80
  "test:watch": "jest --watch",
72
- "test:watch:all": "jest --watchAll"
81
+ "test:watch:all": "jest --watchAll",
82
+ "preinstall": "npx only-allow bun"
83
+ },
84
+ "version": "0.0.0-alpha.3",
85
+ "dependencies": {
86
+ "@typescript-eslint/parser": "^8.71.2"
73
87
  }
74
- }
88
+ }