@storm-software/eslint 0.107.2 → 0.108.0
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 +1 -1
- package/dist/chunk-723HQUNP.js +14 -0
- package/dist/{chunk-V7TQDECV.js → chunk-E7T4SNH3.js} +2 -4
- package/dist/chunk-ESFBJFNU.cjs +149 -0
- package/dist/chunk-FTXILLLE.js +24 -0
- package/dist/chunk-JS7W7LMD.cjs +14 -0
- package/dist/chunk-KND2ZTLT.cjs +49 -0
- package/dist/chunk-LSG5T3ZK.js +313 -0
- package/dist/{chunk-CIGM5K4I.cjs → chunk-NFPQICLG.cjs} +2 -4
- package/dist/chunk-OGGLIE6C.cjs +24 -0
- package/dist/chunk-QDLKHXPX.cjs +11 -0
- package/dist/chunk-RTM5LCEB.js +149 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-TXTXUVRZ.cjs +313 -0
- package/dist/chunk-VJ6CKC4P.js +37 -0
- package/dist/chunk-Y67QTC5U.js +49 -0
- package/dist/chunk-YQQ366F7.cjs +37 -0
- package/dist/preset.cjs +169 -20187
- package/dist/preset.js +88 -20104
- package/dist/rules/import.cjs +292 -0
- package/dist/rules/import.d.cts +5 -0
- package/dist/rules/import.d.ts +5 -0
- package/dist/rules/import.js +292 -0
- package/dist/rules/jsx-a11y.cjs +341 -0
- package/dist/rules/jsx-a11y.d.cts +5 -0
- package/dist/rules/jsx-a11y.d.ts +5 -0
- package/dist/rules/jsx-a11y.js +341 -0
- package/dist/rules/react-hooks.cjs +15 -0
- package/dist/rules/react-hooks.d.cts +5 -0
- package/dist/rules/react-hooks.d.ts +5 -0
- package/dist/rules/react-hooks.js +15 -0
- package/dist/rules/react.cjs +689 -0
- package/dist/rules/react.d.cts +5 -0
- package/dist/rules/react.d.ts +5 -0
- package/dist/rules/react.js +689 -0
- package/dist/rules/storm.cjs +3 -3
- package/dist/rules/storm.js +2 -2
- package/dist/rules/ts-docs.cjs +7 -0
- package/dist/rules/ts-docs.d.cts +5 -0
- package/dist/rules/ts-docs.d.ts +5 -0
- package/dist/rules/ts-docs.js +7 -0
- package/dist/utils/banner-plugin.cjs +9 -0
- package/dist/utils/banner-plugin.d.cts +6 -0
- package/dist/utils/banner-plugin.d.ts +6 -0
- package/dist/utils/banner-plugin.js +9 -0
- package/dist/utils/constants.cjs +25 -0
- package/dist/utils/constants.d.cts +24 -0
- package/dist/utils/constants.d.ts +24 -0
- package/dist/utils/constants.js +25 -0
- package/dist/utils/create-flat-import-plugin.cjs +20 -0
- package/dist/utils/create-flat-import-plugin.d.cts +11 -0
- package/dist/utils/create-flat-import-plugin.d.ts +11 -0
- package/dist/utils/create-flat-import-plugin.js +20 -0
- package/dist/utils/format-config.cjs +7 -0
- package/dist/utils/format-config.d.cts +5 -0
- package/dist/utils/format-config.d.ts +5 -0
- package/dist/utils/format-config.js +7 -0
- package/dist/utils/get-file-banner.cjs +8 -0
- package/dist/utils/get-file-banner.d.cts +9 -0
- package/dist/utils/get-file-banner.d.ts +9 -0
- package/dist/utils/get-file-banner.js +8 -0
- package/dist/utils/ignores.cjs +7 -0
- package/dist/utils/ignores.d.cts +3 -0
- package/dist/utils/ignores.d.ts +3 -0
- package/dist/utils/ignores.js +7 -0
- package/dist/utils/index.cjs +33 -0
- package/dist/utils/index.d.cts +4 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +33 -0
- package/package.json +1 -1
- package/dist/acorn-CCDA5Y7C.cjs +0 -3131
- package/dist/acorn-PTPZSZS6.js +0 -3131
- package/dist/angular-NDZ53HZT.js +0 -3014
- package/dist/angular-XXKPBORI.cjs +0 -3014
- package/dist/babel-7OKY5N6D.js +0 -7166
- package/dist/babel-ZAEH2MD6.cjs +0 -7166
- package/dist/chunk-2GN5RLNR.js +0 -55
- package/dist/chunk-BHJDUHOW.cjs +0 -84
- package/dist/chunk-GSOR5H2M.cjs +0 -4022
- package/dist/chunk-HXTIVITI.js +0 -4022
- package/dist/chunk-KOFZWJCN.js +0 -84
- package/dist/chunk-PWYAFNCE.cjs +0 -59
- package/dist/dist-3EJMVSVL.js +0 -15716
- package/dist/dist-GB3FBWYD.cjs +0 -15717
- package/dist/esm-HMD4VZC2.js +0 -1715
- package/dist/esm-KLBQYHBS.cjs +0 -1715
- package/dist/estree-4FZVBA3I.js +0 -4859
- package/dist/estree-TXEM7J44.cjs +0 -4859
- package/dist/execa-6ZJHRRGH.js +0 -2424
- package/dist/execa-RWXGY3AF.cjs +0 -2424
- package/dist/flow-LEJXBIDN.cjs +0 -28076
- package/dist/flow-TYUDSDMT.js +0 -28076
- package/dist/glimmer-BFX2N2PO.js +0 -3062
- package/dist/glimmer-CI4NLBJN.cjs +0 -3062
- package/dist/graphql-ATKH2UJU.js +0 -1355
- package/dist/graphql-F26LLKM2.cjs +0 -1355
- package/dist/html-DPSCSLFD.cjs +0 -3036
- package/dist/html-TQZJETBK.js +0 -3036
- package/dist/json5-2N47OU6X.cjs +0 -764
- package/dist/json5-DGCDZGKI.js +0 -764
- package/dist/jsonc-3RGXS4EK.js +0 -447
- package/dist/jsonc-H5JHBJWX.cjs +0 -447
- package/dist/markdown-ENFWQVL3.js +0 -3846
- package/dist/markdown-KDQOGP3N.cjs +0 -3846
- package/dist/meriyah-UO5W2QS6.js +0 -2720
- package/dist/meriyah-XW3PRYEN.cjs +0 -2720
- package/dist/multipart-parser-POHWNSZ2.cjs +0 -186
- package/dist/multipart-parser-ZBOXYK27.js +0 -186
- package/dist/postcss-ICZTIVVB.js +0 -5440
- package/dist/postcss-OH45GBM4.cjs +0 -5440
- package/dist/prettier-U5XWBEA6.js +0 -23559
- package/dist/prettier-UYPX4PW2.cjs +0 -23560
- package/dist/toml-NUWFIHJI.js +0 -509
- package/dist/toml-WFSEGMHQ.cjs +0 -509
- package/dist/typescript-6RS3BOJH.js +0 -14956
- package/dist/typescript-K6YYG6NX.cjs +0 -14956
- package/dist/yaml-DOGTEZV3.js +0 -4584
- package/dist/yaml-GNGUKHFM.cjs +0 -4584
- package/dist/yaml-UATHGD5B.cjs +0 -1119
- package/dist/yaml-XTDKP6DN.js +0 -1119
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/rules/ts-docs.ts
|
|
2
|
+
var config = {
|
|
3
|
+
/**
|
|
4
|
+
* Require TSDoc comments conform to the TSDoc specification.
|
|
5
|
+
*
|
|
6
|
+
* 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
|
|
7
|
+
*/
|
|
8
|
+
"tsdoc/syntax": "warn"
|
|
9
|
+
};
|
|
10
|
+
var ts_docs_default = config;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
ts_docs_default
|
|
14
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__name
|
|
3
|
-
|
|
4
|
-
} from "./chunk-2GN5RLNR.js";
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-SHUYVCID.js";
|
|
5
4
|
|
|
6
5
|
// src/rules/storm.ts
|
|
7
|
-
init_esm_shims();
|
|
8
6
|
var getStormRulesConfig = /* @__PURE__ */ __name((options) => {
|
|
9
7
|
let rules = {
|
|
10
8
|
/*************************************************************
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/constants.ts
|
|
2
|
+
var RESTRICTED_SYNTAX = [
|
|
3
|
+
{
|
|
4
|
+
// ❌ readFile(…, { encoding: … })
|
|
5
|
+
selector: "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
|
|
6
|
+
message: "Specify encoding as last argument instead of object with encoding key"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
// ❌ readFile(…, {})
|
|
10
|
+
selector: "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
|
|
11
|
+
message: "Specify encoding as last argument"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
// ❌ readFileSync(…).toString(…)
|
|
15
|
+
selector: "CallExpression[callee.name=readFileSync][parent.property.name=toString]",
|
|
16
|
+
message: "toString is redundant, specify encoding as last argument"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
// ❌ ….readFile(…, { encoding: … })
|
|
20
|
+
selector: "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
|
|
21
|
+
message: "Specify encoding as last argument instead of object with encoding key"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// ❌ ….readFile(…, {})
|
|
25
|
+
selector: "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
|
|
26
|
+
message: "Specify encoding as last argument"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
// ❌ Boolean(…)
|
|
30
|
+
selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
|
|
31
|
+
message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
// ❌ process.browser
|
|
35
|
+
selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
|
|
36
|
+
message: "`process.browser` is deprecated, use `!!globalThis.window`"
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
var REACT_RESTRICTED_SYNTAX = [
|
|
40
|
+
...RESTRICTED_SYNTAX,
|
|
41
|
+
{
|
|
42
|
+
// ❌ useMemo(…, [])
|
|
43
|
+
selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
|
|
44
|
+
message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
var RESTRICTED_GLOBALS = [
|
|
48
|
+
"stop",
|
|
49
|
+
{
|
|
50
|
+
name: "isNaN",
|
|
51
|
+
message: "Use Number.isNaN instead"
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
var RESTRICTED_MODULES = [
|
|
55
|
+
{
|
|
56
|
+
name: "axios",
|
|
57
|
+
message: "Use `fetch/node-fetch` instead."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "moment",
|
|
61
|
+
message: "Use `dayjs/date-fns` instead."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "classnames",
|
|
65
|
+
message: "Use `clsx` instead because it is faster."
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "lodash/isString.js",
|
|
69
|
+
message: "Use `typeof yourVar === 'string'` instead."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "lodash/isArray.js",
|
|
73
|
+
message: "Use `Array.isArray` instead."
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "lodash/flatten.js",
|
|
77
|
+
message: "Use `Array#flat()` instead."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "lodash/compact.js",
|
|
81
|
+
message: "Use `Array#filter(Boolean)` instead."
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "lodash/identity.js",
|
|
85
|
+
message: "Use `(value) => value` instead."
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
var JS_FILES = [
|
|
89
|
+
"*.js?(x)",
|
|
90
|
+
"*.mjs"
|
|
91
|
+
];
|
|
92
|
+
var CODE_BLOCK = "**/*.md{,x}/*";
|
|
93
|
+
var CODE_FILE = "**/*.{,c,m}{j,t}s{,x}";
|
|
94
|
+
var TS_FILE = "**/*.{,c,m}ts{,x}";
|
|
95
|
+
var JS_FILE = "**/*.{,c}js{,x}";
|
|
96
|
+
var ACRONYMS_LIST = [
|
|
97
|
+
"API",
|
|
98
|
+
"ASCII",
|
|
99
|
+
"CPU",
|
|
100
|
+
"CSS",
|
|
101
|
+
"DNS",
|
|
102
|
+
"EOF",
|
|
103
|
+
"GUID",
|
|
104
|
+
"HTML",
|
|
105
|
+
"HTTP",
|
|
106
|
+
"HTTPS",
|
|
107
|
+
"ID",
|
|
108
|
+
"IP",
|
|
109
|
+
"JSON",
|
|
110
|
+
"LHS",
|
|
111
|
+
"OEM",
|
|
112
|
+
"PP",
|
|
113
|
+
"QA",
|
|
114
|
+
"RAM",
|
|
115
|
+
"RHS",
|
|
116
|
+
"RPC",
|
|
117
|
+
"RSS",
|
|
118
|
+
"SLA",
|
|
119
|
+
"SMTP",
|
|
120
|
+
"SQL",
|
|
121
|
+
"SSH",
|
|
122
|
+
"SSL",
|
|
123
|
+
"TCP",
|
|
124
|
+
"TLS",
|
|
125
|
+
"TTL",
|
|
126
|
+
"UDP",
|
|
127
|
+
"UI",
|
|
128
|
+
"UID",
|
|
129
|
+
"UUID",
|
|
130
|
+
"URI",
|
|
131
|
+
"URL",
|
|
132
|
+
"UTF",
|
|
133
|
+
"VM",
|
|
134
|
+
"XML",
|
|
135
|
+
"XSS"
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
exports.RESTRICTED_SYNTAX = RESTRICTED_SYNTAX; exports.REACT_RESTRICTED_SYNTAX = REACT_RESTRICTED_SYNTAX; exports.RESTRICTED_GLOBALS = RESTRICTED_GLOBALS; exports.RESTRICTED_MODULES = RESTRICTED_MODULES; exports.JS_FILES = JS_FILES; exports.CODE_BLOCK = CODE_BLOCK; exports.CODE_FILE = CODE_FILE; exports.TS_FILE = TS_FILE; exports.JS_FILE = JS_FILE; exports.ACRONYMS_LIST = ACRONYMS_LIST;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-SHUYVCID.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/format-config.ts
|
|
6
|
+
var formatConfig = /* @__PURE__ */ __name((name, config = []) => {
|
|
7
|
+
return config.map((config2, index) => {
|
|
8
|
+
if (!config2 || config2.name) {
|
|
9
|
+
return config2 ?? {};
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...config2,
|
|
13
|
+
name: `Storm Software (${config2.name ? config2.name : name}) #${index + 1}`,
|
|
14
|
+
settings: {
|
|
15
|
+
"import/resolver": "node",
|
|
16
|
+
...config2.settings ?? {}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}, "formatConfig");
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
formatConfig
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/rules/ts-docs.ts
|
|
2
|
+
var config = {
|
|
3
|
+
/**
|
|
4
|
+
* Require TSDoc comments conform to the TSDoc specification.
|
|
5
|
+
*
|
|
6
|
+
* 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
|
|
7
|
+
*/
|
|
8
|
+
"tsdoc/syntax": "warn"
|
|
9
|
+
};
|
|
10
|
+
var ts_docs_default = config;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.ts_docs_default = ts_docs_default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkESFBJFNUcjs = require('./chunk-ESFBJFNU.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQDLKHXPXcjs = require('./chunk-QDLKHXPX.cjs');
|
|
7
|
+
|
|
8
|
+
// src/utils/get-file-banner.ts
|
|
9
|
+
var getFileBanner = /* @__PURE__ */ _chunkQDLKHXPXcjs.__name.call(void 0, (name = "") => {
|
|
10
|
+
if (!name) {
|
|
11
|
+
name = process.env.STORM_NAMESPACE || "";
|
|
12
|
+
}
|
|
13
|
+
let padding = " ";
|
|
14
|
+
for (let i = 0; i < name.length + 2 && padding.length > 4; i++) {
|
|
15
|
+
padding = padding.slice(0, -1);
|
|
16
|
+
}
|
|
17
|
+
let titleName = name;
|
|
18
|
+
if (titleName) {
|
|
19
|
+
if (_optionalChain([titleName, 'optionalAccess', _ => _.startsWith, 'call', _2 => _2("@")])) {
|
|
20
|
+
titleName = titleName.slice(1);
|
|
21
|
+
}
|
|
22
|
+
titleName = (titleName.charAt(0).toUpperCase() + titleName.slice(1)).split("-").filter((word) => word && word.length > 0).map((word) => {
|
|
23
|
+
if (_chunkESFBJFNUcjs.ACRONYMS_LIST.includes(word.toUpperCase())) {
|
|
24
|
+
return word.toUpperCase();
|
|
25
|
+
}
|
|
26
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
27
|
+
}).join(" ");
|
|
28
|
+
}
|
|
29
|
+
return `-------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
${padding}\u26A1 Storm Software ${titleName ? `- ${titleName}` : ""}
|
|
32
|
+
|
|
33
|
+
This code was released as part of ${titleName ? `the ${titleName}` : "a Storm Software"} project. ${titleName ? titleName : "The project"}
|
|
34
|
+
is maintained by Storm Software under the ${_optionalChain([(_nullishCoalesce(process.env.STORM_LICENSE, () => ( "Apache-2.0"))), 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4(), 'optionalAccess', _5 => _5.includes, 'call', _6 => _6("license")]) ? _nullishCoalesce(process.env.STORM_LICENSE, () => ( "Apache-2.0")) : `${_nullishCoalesce(process.env.STORM_LICENSE, () => ( "Apache-2.0"))} License`}, and is
|
|
35
|
+
free for commercial and private use. For more information, please visit
|
|
36
|
+
our licensing page.
|
|
37
|
+
|
|
38
|
+
Website: ${_nullishCoalesce(process.env.STORM_HOMEPAGE, () => ( "https://stormsoftware.com"))}
|
|
39
|
+
Repository: ${_nullishCoalesce(process.env.STORM_REPOSITORY, () => ( `https://github.com/storm-software${name ? `/${name}` : ""}`))}
|
|
40
|
+
Documentation: ${process.env.STORM_DOCS ? process.env.STORM_DOCS : `https://stormsoftware.com/${name ? `projects/${name}/` : ""}docs`}
|
|
41
|
+
Contact: ${process.env.STORM_HOMEPAGE ? process.env.STORM_HOMEPAGE.endsWith("/") ? process.env.STORM_HOMEPAGE.slice(-1) : process.env.STORM_HOMEPAGE : "https://stormsoftware.com"}/contact
|
|
42
|
+
License: ${process.env.STORM_LICENSING ? process.env.STORM_LICENSING : `https://stormsoftware.com/${name ? `projects/${name}/` : ""}license`}
|
|
43
|
+
|
|
44
|
+
-------------------------------------------------------------------`;
|
|
45
|
+
}, "getFileBanner");
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
exports.getFileBanner = getFileBanner;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getFileBanner
|
|
3
|
+
} from "./chunk-Y67QTC5U.js";
|
|
4
|
+
import {
|
|
5
|
+
CODE_FILE
|
|
6
|
+
} from "./chunk-RTM5LCEB.js";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-SHUYVCID.js";
|
|
10
|
+
|
|
11
|
+
// src/utils/banner-plugin.ts
|
|
12
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
13
|
+
import os from "node:os";
|
|
14
|
+
function match(actual, expected) {
|
|
15
|
+
if (expected.test) {
|
|
16
|
+
return expected.test(actual);
|
|
17
|
+
} else {
|
|
18
|
+
return expected === actual;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__name(match, "match");
|
|
22
|
+
function excludeShebangs(comments) {
|
|
23
|
+
return comments.filter(function(comment) {
|
|
24
|
+
return comment.type !== "Shebang";
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
__name(excludeShebangs, "excludeShebangs");
|
|
28
|
+
function getLeadingComments(context, node) {
|
|
29
|
+
const all = excludeShebangs(context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node));
|
|
30
|
+
if (all[0].type.toLowerCase() === "block") {
|
|
31
|
+
return [
|
|
32
|
+
all[0]
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
let i = 1;
|
|
36
|
+
for (i = 1; i < all.length; ++i) {
|
|
37
|
+
const txt = context.getSourceCode().getText().slice(all[i - 1].range[1], all[i].range[0]);
|
|
38
|
+
if (!txt.match(/^(\r\n|\r|\n)$/)) {
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return all.slice(0, i);
|
|
43
|
+
}
|
|
44
|
+
__name(getLeadingComments, "getLeadingComments");
|
|
45
|
+
function genCommentBody(commentType, textArray, eol, numNewlines) {
|
|
46
|
+
const eols = eol.repeat(numNewlines);
|
|
47
|
+
if (commentType === "block") {
|
|
48
|
+
return "/*" + textArray.join(eol) + "*/" + eols;
|
|
49
|
+
} else {
|
|
50
|
+
return "//" + textArray.join(eol + "//") + eols;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
__name(genCommentBody, "genCommentBody");
|
|
54
|
+
function genCommentsRange(context, comments, eol) {
|
|
55
|
+
const start = comments[0].range[0];
|
|
56
|
+
let end = comments.slice(-1)[0].range[1];
|
|
57
|
+
if (context.getSourceCode().text[end] === eol) {
|
|
58
|
+
end += eol.length;
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
start,
|
|
62
|
+
end
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
__name(genCommentsRange, "genCommentsRange");
|
|
66
|
+
function genPrependFixer(commentType, node, bannerLines, eol, numNewlines) {
|
|
67
|
+
return function(fixer) {
|
|
68
|
+
return fixer.insertTextBefore(node, genCommentBody(commentType, bannerLines, eol, numNewlines));
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
__name(genPrependFixer, "genPrependFixer");
|
|
72
|
+
function genReplaceFixer(commentType, context, leadingComments, bannerLines, eol, numNewlines) {
|
|
73
|
+
return function(fixer) {
|
|
74
|
+
return fixer.replaceTextRange(genCommentsRange(context, leadingComments, eol), genCommentBody(commentType, bannerLines, eol, numNewlines));
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
__name(genReplaceFixer, "genReplaceFixer");
|
|
78
|
+
function getEOL(options) {
|
|
79
|
+
if (options.lineEndings === "unix") {
|
|
80
|
+
return "\n";
|
|
81
|
+
}
|
|
82
|
+
if (options.lineEndings === "windows") {
|
|
83
|
+
return "\r\n";
|
|
84
|
+
}
|
|
85
|
+
return os.EOL;
|
|
86
|
+
}
|
|
87
|
+
__name(getEOL, "getEOL");
|
|
88
|
+
function hasBanner(commentType, src) {
|
|
89
|
+
if (src.startsWith("#!")) {
|
|
90
|
+
const bannerLines = src.split(/\r?\n/);
|
|
91
|
+
if (bannerLines && bannerLines.length > 1) {
|
|
92
|
+
bannerLines.shift();
|
|
93
|
+
while (bannerLines.length && bannerLines[0] && !bannerLines[0].replace(/\s+/, "")) {
|
|
94
|
+
bannerLines.shift();
|
|
95
|
+
}
|
|
96
|
+
if (bannerLines.length) {
|
|
97
|
+
src = bannerLines.join("\n");
|
|
98
|
+
} else {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return commentType === "block" && src.startsWith("/*") || commentType === "lint" && src.startsWith("//") || commentType !== "block" && commentType !== "lint" && commentType && src.startsWith(commentType);
|
|
104
|
+
}
|
|
105
|
+
__name(hasBanner, "hasBanner");
|
|
106
|
+
function matchesLineEndings(src, num) {
|
|
107
|
+
for (let j = 0; j < num; ++j) {
|
|
108
|
+
const m = src.match(/^(\r\n|\r|\n)/);
|
|
109
|
+
if (m) {
|
|
110
|
+
src = src.slice(m.index + m[0].length);
|
|
111
|
+
} else {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
__name(matchesLineEndings, "matchesLineEndings");
|
|
118
|
+
var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/eslint/rules/banner`)({
|
|
119
|
+
name: "banner",
|
|
120
|
+
meta: {
|
|
121
|
+
docs: {
|
|
122
|
+
description: "Ensures the file has a Storm Software banner"
|
|
123
|
+
},
|
|
124
|
+
schema: [
|
|
125
|
+
{
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
banner: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "The banner to enforce at the top of the file. If not provided, the banner will be read from the file specified in the commentStart option"
|
|
131
|
+
},
|
|
132
|
+
repositoryName: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "The name of the repository to use when reading the banner from a file."
|
|
135
|
+
},
|
|
136
|
+
commentType: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "The comment token to use for the banner. Defaults to block ('/* <banner> */')"
|
|
139
|
+
},
|
|
140
|
+
numNewlines: {
|
|
141
|
+
type: "number",
|
|
142
|
+
description: "The number of newlines to use after the banner. Defaults to 2"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
additionalProperties: false
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
type: "layout",
|
|
149
|
+
messages: {
|
|
150
|
+
missingBanner: "Missing banner",
|
|
151
|
+
incorrectComment: "Banner should use the {{commentType}} comment type",
|
|
152
|
+
incorrectBanner: "Incorrect banner",
|
|
153
|
+
noNewlineAfterBanner: "No newline after banner"
|
|
154
|
+
},
|
|
155
|
+
fixable: "whitespace"
|
|
156
|
+
},
|
|
157
|
+
defaultOptions: [
|
|
158
|
+
{
|
|
159
|
+
repositoryName: "",
|
|
160
|
+
commentType: "block",
|
|
161
|
+
numNewlines: 2
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
create(context, [{ banner, repositoryName = "", commentType = "block", numNewlines = 2 }]) {
|
|
165
|
+
if (!banner) {
|
|
166
|
+
banner = getFileBanner(repositoryName);
|
|
167
|
+
}
|
|
168
|
+
const options = context.options;
|
|
169
|
+
const eol = getEOL(options);
|
|
170
|
+
const canFix = true;
|
|
171
|
+
const bannerLines = banner.split(/\r?\n/);
|
|
172
|
+
let fixLines = bannerLines;
|
|
173
|
+
return {
|
|
174
|
+
Program: /* @__PURE__ */ __name(function(node) {
|
|
175
|
+
if (!hasBanner(commentType, context.sourceCode.getText())) {
|
|
176
|
+
context.report({
|
|
177
|
+
loc: node.loc,
|
|
178
|
+
messageId: "missingBanner",
|
|
179
|
+
fix: genPrependFixer(commentType, node, fixLines, eol, numNewlines)
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
const leadingComments = getLeadingComments(context, node);
|
|
183
|
+
if (!leadingComments.length) {
|
|
184
|
+
context.report({
|
|
185
|
+
loc: node.loc,
|
|
186
|
+
messageId: "missingBanner",
|
|
187
|
+
fix: canFix ? genPrependFixer(commentType, node, fixLines, eol, numNewlines) : null
|
|
188
|
+
});
|
|
189
|
+
} else if (leadingComments[0].type.toLowerCase() !== commentType) {
|
|
190
|
+
context.report({
|
|
191
|
+
loc: node.loc,
|
|
192
|
+
messageId: "incorrectComment",
|
|
193
|
+
data: {
|
|
194
|
+
commentType
|
|
195
|
+
},
|
|
196
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
197
|
+
});
|
|
198
|
+
} else {
|
|
199
|
+
if (commentType === "line") {
|
|
200
|
+
if (leadingComments.length < bannerLines.length) {
|
|
201
|
+
context.report({
|
|
202
|
+
loc: node.loc,
|
|
203
|
+
messageId: "missingBanner",
|
|
204
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
205
|
+
});
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
for (let i = 0; i < bannerLines.length; i++) {
|
|
209
|
+
if (!match(leadingComments[i].value, bannerLines[i])) {
|
|
210
|
+
context.report({
|
|
211
|
+
loc: node.loc,
|
|
212
|
+
messageId: "incorrectBanner",
|
|
213
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const postLineBanner = context.getSourceCode().text.substr(leadingComments[bannerLines.length - 1].range[1], (numNewlines ?? 1) * 2);
|
|
219
|
+
if (!matchesLineEndings(postLineBanner, numNewlines)) {
|
|
220
|
+
context.report({
|
|
221
|
+
loc: node.loc,
|
|
222
|
+
messageId: "noNewlineAfterBanner",
|
|
223
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
let leadingLines = [
|
|
228
|
+
leadingComments[0].value
|
|
229
|
+
];
|
|
230
|
+
if (bannerLines.length > 1) {
|
|
231
|
+
leadingLines = leadingComments[0].value.split(/\r?\n/);
|
|
232
|
+
}
|
|
233
|
+
let hasError = false;
|
|
234
|
+
if (leadingLines.length > bannerLines.length) {
|
|
235
|
+
hasError = true;
|
|
236
|
+
}
|
|
237
|
+
for (let i = 0; !hasError && i < bannerLines.length; i++) {
|
|
238
|
+
if (!match(leadingLines[i], bannerLines[i])) {
|
|
239
|
+
hasError = true;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (hasError) {
|
|
243
|
+
if (canFix && bannerLines.length > 1) {
|
|
244
|
+
fixLines = [
|
|
245
|
+
fixLines.join(eol)
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
context.report({
|
|
249
|
+
loc: node.loc,
|
|
250
|
+
messageId: "incorrectBanner",
|
|
251
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
252
|
+
});
|
|
253
|
+
} else {
|
|
254
|
+
const postBlockBanner = context.getSourceCode().text.substr(leadingComments[0].range[1], (numNewlines ?? 1) * 2);
|
|
255
|
+
if (!matchesLineEndings(postBlockBanner, numNewlines)) {
|
|
256
|
+
context.report({
|
|
257
|
+
loc: node.loc,
|
|
258
|
+
messageId: "noNewlineAfterBanner",
|
|
259
|
+
fix: canFix ? genReplaceFixer(commentType, context, leadingComments, fixLines, eol, numNewlines) : null
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}, "Program")
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
var plugin = {
|
|
271
|
+
meta: {
|
|
272
|
+
name: "eslint-plugin-banner",
|
|
273
|
+
version: "0.0.1"
|
|
274
|
+
},
|
|
275
|
+
configs: {},
|
|
276
|
+
rules: {
|
|
277
|
+
banner: bannerRule
|
|
278
|
+
},
|
|
279
|
+
processors: {}
|
|
280
|
+
};
|
|
281
|
+
plugin.configs && (plugin.configs.recommended = {
|
|
282
|
+
name: "banner/recommended",
|
|
283
|
+
plugins: {
|
|
284
|
+
banner: plugin
|
|
285
|
+
},
|
|
286
|
+
files: [
|
|
287
|
+
CODE_FILE
|
|
288
|
+
],
|
|
289
|
+
ignores: [
|
|
290
|
+
"!**/docs/**/*",
|
|
291
|
+
"!**/crates/**/*",
|
|
292
|
+
"!**/tmp/**/*",
|
|
293
|
+
"!**/dist/**/*",
|
|
294
|
+
"!**/coverage/**/*",
|
|
295
|
+
"!**/node_modules/**/*",
|
|
296
|
+
"!**/.cache/**/*",
|
|
297
|
+
"!**/.nx/**/*"
|
|
298
|
+
],
|
|
299
|
+
rules: {
|
|
300
|
+
"banner/banner": [
|
|
301
|
+
"error",
|
|
302
|
+
{
|
|
303
|
+
commentType: "block",
|
|
304
|
+
numNewlines: 2
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
var banner_plugin_default = plugin;
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
banner_plugin_default
|
|
313
|
+
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var _chunkPWYAFNCEcjs = require('./chunk-PWYAFNCE.cjs');
|
|
3
|
+
var _chunkQDLKHXPXcjs = require('./chunk-QDLKHXPX.cjs');
|
|
5
4
|
|
|
6
5
|
// src/rules/storm.ts
|
|
7
|
-
|
|
8
|
-
var getStormRulesConfig = /* @__PURE__ */ _chunkPWYAFNCEcjs.__name.call(void 0, (options) => {
|
|
6
|
+
var getStormRulesConfig = /* @__PURE__ */ _chunkQDLKHXPXcjs.__name.call(void 0, (options) => {
|
|
9
7
|
let rules = {
|
|
10
8
|
/*************************************************************
|
|
11
9
|
*
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkQDLKHXPXcjs = require('./chunk-QDLKHXPX.cjs');
|
|
4
|
+
|
|
5
|
+
// src/utils/format-config.ts
|
|
6
|
+
var formatConfig = /* @__PURE__ */ _chunkQDLKHXPXcjs.__name.call(void 0, (name, config = []) => {
|
|
7
|
+
return config.map((config2, index) => {
|
|
8
|
+
if (!config2 || config2.name) {
|
|
9
|
+
return _nullishCoalesce(config2, () => ( {}));
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...config2,
|
|
13
|
+
name: `Storm Software (${config2.name ? config2.name : name}) #${index + 1}`,
|
|
14
|
+
settings: {
|
|
15
|
+
"import/resolver": "node",
|
|
16
|
+
..._nullishCoalesce(config2.settings, () => ( {}))
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
}, "formatConfig");
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.formatConfig = formatConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.49.1_@types+node@22.10.5__@swc+core@1.7.26_@swc+helpers_c7mn2udg6r6tcyo4cnski6htca/node_modules/tsup/assets/cjs_shims.js
|
|
5
|
+
var getImportMetaUrl = /* @__PURE__ */ __name(() => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href, "getImportMetaUrl");
|
|
6
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.__name = __name; exports.importMetaUrl = importMetaUrl;
|