@lntvow/eslint-config 9.3.11 → 9.3.12
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.cjs +1099 -1
- package/dist/index.mjs +1017 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1,1099 @@
|
|
|
1
|
-
"use strict";var ge=Object.create;var x=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var we=(e,o)=>{for(var r in o)x(e,r,{get:o[r],enumerable:!0})},M=(e,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of xe(o))!be.call(e,t)&&t!==r&&x(e,t,{get:()=>o[t],enumerable:!(n=ye(o,t))||n.enumerable});return e};var s=(e,o,r)=>(r=e!=null?ge(Oe(e)):{},M(o||!e||!e.__esModule?x(r,"default",{value:e,enumerable:!0}):r,e)),he=e=>M(x({},"__esModule",{value:!0}),e);var Ve={};we(Ve,{GLOB_ALL_SRC:()=>qe,GLOB_ASTRO:()=>Pe,GLOB_CSS:()=>Se,GLOB_EXCLUDE:()=>F,GLOB_GRAPHQL:()=>Ee,GLOB_HTML:()=>re,GLOB_JS:()=>Ce,GLOB_JSON:()=>Y,GLOB_JSON5:()=>Q,GLOB_JSONC:()=>Ie,GLOB_JSX:()=>_e,GLOB_LESS:()=>je,GLOB_MARKDOWN:()=>G,GLOB_MARKDOWN_CODE:()=>Re,GLOB_MARKDOWN_IN_MARKDOWN:()=>Be,GLOB_POSTCSS:()=>Ge,GLOB_SCSS:()=>Fe,GLOB_SRC:()=>l,GLOB_SRC_EXT:()=>m,GLOB_STYLE:()=>z,GLOB_SVELTE:()=>Z,GLOB_TESTS:()=>j,GLOB_TOML:()=>ke,GLOB_TS:()=>Te,GLOB_TSX:()=>Le,GLOB_VUE:()=>b,GLOB_XML:()=>oe,GLOB_YAML:()=>ee,StylisticConfigDefaults:()=>pe,custom:()=>L,getVueVersion:()=>ce,gitignore:()=>S,ignores:()=>I,imports:()=>B,javascript:()=>k,lntvow:()=>de,prettier:()=>P,regexp:()=>R,renameRules:()=>O,stylistic:()=>N,test:()=>A,typescript:()=>V,vue:()=>D});module.exports=he(Ve);function O(e,o){return Object.fromEntries(Object.entries(e).map(([r,n])=>{for(let[t,f]of Object.entries(o))if(r.startsWith(`${t}/`))return[f+r.slice(t.length),n];return[r,n]}))}var K=s(require("@lntvow/eslint-plugin"),1);async function L(){return[{name:"lntvow/custom",plugins:{lntvow:K.default}}]}var X=s(require("fs"),1),J=require("find-up"),W=require("@lntvow/utils"),H=s(require("parse-gitignore"),1);async function S(e){let{name:o=".gitignore",root:r=!1,files:n=r?o:(0,J.findUpSync)(o)||[]}=e,t=(0,W.castArray)(n),f=[];for(let v of t)try{let d=X.default.readFileSync(v,"utf8"),_=(0,H.default)(d).globs();for(let c of _)c.type==="ignore"?f.push(...c.patterns):c.type==="unignore"&&f.push(...c.patterns.map(p=>`!${p}`))}catch{throw new Error(`Failed to read file: ${v}`)}return[{ignores:f}]}var m="?([cm])[jt]s?(x)",l="**/*.?([cm])[jt]s?(x)",Ce="**/*.?([cm])js",_e="**/*.?([cm])jsx",Te="**/*.?([cm])ts",Le="**/*.?([cm])tsx",z="**/*.{c,le,sc}ss",Se="**/*.css",Ge="**/*.{p,post}css",je="**/*.less",Fe="**/*.scss",Y="**/*.json",Q="**/*.json5",Ie="**/*.jsonc",G="**/*.md",Be="**/*.md/*.md",Z="**/*.svelte",b="**/*.vue",ee="**/*.y?(a)ml",ke="**/*.toml",oe="**/*.xml",re="**/*.htm?(l)",Pe="**/*.astro",Ee="**/*.{g,graph}ql",Re=`${G}/${l}`,j=[`**/__tests__/**/*.${m}`,`**/*.spec.${m}`,`**/*.test.${m}`,`**/*.bench.${m}`,`**/*.benchmark.${m}`],qe=[l,z,Y,Q,G,Z,b,ee,oe,re],F=["**/node_modules","**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/bun.lockb","**/output","**/coverage","**/temp","**/.temp","**/tmp","**/.tmp","**/.history","**/.vitepress/cache","**/.nuxt","**/.next","**/.vercel","**/.changeset","**/.idea","**/.cache","**/.output","**/.vite-inspect","**/.yarn","**/CHANGELOG*.md","**/*.min.*","**/LICENSE*","**/__snapshots__","**/auto-import?(s).d.ts","**/components.d.ts"];async function I(){return[{ignores:[...F]}]}var te=s(require("eslint-plugin-import-x"),1);async function B(){return[{name:"lntvow/imports/rules",plugins:{import:te.default},rules:{"import/order":"error","import/newline-after-import":"error"}}]}var ne=s(require("@eslint/js"),1),w=s(require("globals"),1);async function k(e={}){let{overrides:o={}}=e;return[{name:"lntvow/javascript/rules",languageOptions:{ecmaVersion:2022,sourceType:"module",parserOptions:{ecmaVersion:2022,sourceType:"module",ecmaFeatures:{jsx:!0}},globals:{...w.default.browser,...w.default.es2021,...w.default.node,document:"readonly",navigator:"readonly",window:"readonly"}},linterOptions:{reportUnusedDisableDirectives:!0},rules:{...ne.default.configs.all.rules,"no-unused-vars":"warn","no-use-before-define":["error",{functions:!1,variables:!1}],"no-useless-assignment":"off","require-atomic-updates":"off",camelcase:"warn","capitalized-comments":"off","class-methods-use-this":"off",complexity:"off",curly:["error","multi-line"],"func-names":"off","func-style":"off","guard-for-in":"off","id-denylist":"off","id-length":"off","id-match":"off","init-declarations":"off","max-classes-per-file":"off","max-depth":"off","max-lines":"off","max-lines-per-function":"off","max-nested-callbacks":"off","max-params":"off","max-statements":"off","new-cap":["error",{capIsNew:!1}],"no-bitwise":"off","no-case-declarations":"off","no-console":"warn","no-continue":"off","no-empty":["error",{allowEmptyCatch:!0}],"no-implicit-coercion":"off","no-implicit-globals":"off","no-magic-numbers":0,"no-nested-ternary":"off","no-new":"off","no-param-reassign":"off","no-plusplus":"off","no-restricted-exports":"off","no-restricted-globals":["error",{message:"Use `globalThis` instead.",name:"global"},{message:"Use `globalThis` instead.",name:"self"}],"no-restricted-imports":"off","no-restricted-properties":["error",{message:"Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.",property:"__proto__"},{message:"Use `Object.defineProperty` instead.",property:"__defineGetter__"},{message:"Use `Object.defineProperty` instead.",property:"__defineSetter__"},{message:"Use `Object.getOwnPropertyDescriptor` instead.",property:"__lookupGetter__"},{message:"Use `Object.getOwnPropertyDescriptor` instead.",property:"__lookupSetter__"}],"no-restricted-syntax":"off","no-shadow":"off","no-ternary":"off","no-throw-literal":"off","no-undefined":"off","no-underscore-dangle":"off","no-void":"off","no-warning-comments":"off","one-var":"off","prefer-exponentiation-operator":"off","prefer-promise-reject-errors":"off",radix:"off","require-await":"off","require-unicode-regexp":"off","sort-imports":"off","sort-keys":"off","sort-vars":"off",strict:"off",...o}},{files:[`scripts/${l}`],name:"lntvow/javascript/disables",rules:{"no-console":"off"}}]}var se=s(require("eslint-plugin-prettier"),1),ie=s(require("eslint-config-prettier"),1);async function P(){return[{name:"lntvow/prettier/rules",plugins:{prettier:se.default},rules:{...ie.default.rules,"prettier/prettier":"warn"}}]}var E=require("eslint-plugin-regexp");async function R(e={}){let{overrides:o}=e,r=E.configs["flat/recommended"].plugins.regexp,{rules:n}=E.configs["flat/recommended"];return[{name:"lntvow/regexp/rules",plugins:{regexp:r},rules:{...n,...o}}]}var q=s(require("@stylistic/eslint-plugin"),1),pe={indent:2,jsx:!0,quotes:"single",semi:!1};async function N(e={}){let{indent:o,jsx:r,overrides:n={},quotes:t,semi:f}={...pe,...e},v=q.default.configs.customize({flat:!0,indent:o,jsx:r,pluginName:"style",quotes:t,semi:f});return[{name:"lntvow/stylistic/rules",plugins:{style:q.default},rules:{"style/spaced-comment":"error","style/padding-line-between-statements":["error",{blankLine:"always",prev:"*",next:"cjs-export"},{blankLine:"always",prev:"*",next:"export"},{blankLine:"always",prev:"*",next:"function"}],...n}}]}var fe=s(require("eslint-plugin-vitest"),1);async function A(e={}){let{overrides:o}=e;return[{name:"lntvow/test/setup",plugins:{test:fe.default}},{name:"lntvow/test/rules",files:[...j],rules:{"lntvow/newline-before-describe-test":"error",...o}}]}var h=s(require("@typescript-eslint/eslint-plugin"),1),ae=s(require("@typescript-eslint/parser"),1);async function V(e={}){let{componentExts:o=[],overrides:r={},parserOptions:n={}}=e,t=[l,...o.map(f=>`**/*.${f}`)];return[{name:"lntvow/typescript/setup",plugins:{ts:h.default}},{name:"lntvow/typescript/rules",languageOptions:{parser:ae.default,parserOptions:{sourceType:"module"}},files:t,rules:{...O(h.default.configs["eslint-recommended"].overrides[0].rules,{"@typescript-eslint":"ts"}),...O(h.default.configs.strict.rules,{"@typescript-eslint":"ts"}),"ts/no-non-null-assertion":"off","ts/no-explicit-any":"off","ts/ban-ts-comment":"off","ts/no-unused-vars":"warn","no-use-before-define":"off","ts/no-use-before-define":["error",{functions:!1,variables:!1}],...r}}]}var le=require("local-pkg"),U=s(require("@typescript-eslint/parser"),1),ue=s(require("vue-eslint-parser"),1),a=s(require("eslint-plugin-vue"),1);async function D(e={}){let{overrides:o={},vueVersion:r=ce()}=e,n={...a.default.configs["vue3-essential"].rules,...a.default.configs["vue3-strongly-recommended"].rules,...a.default.configs["vue3-recommended"].rules,"vue/block-lang":["error",{script:{lang:["ts","tsx"]}}],"vue/block-order":["error",{order:["script[setup]","template","style[scoped]"]}],"vue/component-api-style":"error"},t={...a.default.configs.essential.rules,...a.default.configs["strongly-recommended"].rules,...a.default.configs.recommended.rules,"vue/block-lang":["error",{script:{allowNoLang:!0}}],"vue/block-order":["error",{order:[["script","template"],"style[scoped]"]}]};return[{name:"lntvow/vue/setup",plugins:{vue:a.default}},{name:"lntvow/vue/rules",languageOptions:{parser:ue.default,parserOptions:{ecmaFeatures:{jsx:!0},parser:{ts:U.default,tsx:U.default},sourceType:"module"}},processor:a.default.processors[".vue"],files:[b],rules:{...a.default.configs.base.rules,...r===3?n:t,"vue/multi-word-component-names":"off","vue/attribute-hyphenation":["error","never"],"vue/html-indent":"off","vue/html-self-closing":["error",{html:{void:"always",normal:"always",component:"always"},svg:"always",math:"always"}],"vue/max-attributes-per-line":"off","vue/singleline-html-element-content-newline":"off","vue/v-on-event-hyphenation":["error","never"],"vue/block-tag-newline":"error","vue/component-name-in-template-casing":["error","PascalCase",{ignores:["/-/"]}],"vue/component-options-name-casing":"error","vue/custom-event-name-casing":"error","vue/define-emits-declaration":"error","vue/define-macros-order":"error","vue/define-props-declaration":"error","vue/enforce-style-attribute":"error","vue/html-button-has-type":"off","vue/html-comment-content-newline":"error","vue/html-comment-content-spacing":"error","vue/html-comment-indent":"off","vue/match-component-file-name":["error",{extensions:["jsx","tsx"],shouldMatchCase:!0}],"vue/match-component-import-name":"error","vue/max-lines-per-block":"off","vue/new-line-between-multi-line-property":"off","vue/next-tick-style":"off","vue/no-bare-strings-in-template":"off","vue/no-boolean-default":"off","vue/no-deprecated-model-definition":"error","vue/no-duplicate-attr-inheritance":"error","vue/no-empty-component-block":"off","vue/no-multiple-objects-in-class":"error","vue/no-potential-component-option-typo":"error","vue/no-ref-object-reactivity-loss":"error","vue/no-required-prop-with-default":"error","vue/no-restricted-block":"off","vue/no-restricted-call-after-await":"off","vue/no-restricted-class":"off","vue/no-restricted-component-names":"off","vue/no-restricted-component-options":"off","vue/no-restricted-custom-event":"off","vue/no-restricted-html-elements":"off","vue/no-restricted-props":"off","vue/no-restricted-static-attribute":"off","vue/no-restricted-v-bind":"off","vue/no-root-v-if":"off","vue/no-setup-props-reactivity-loss":"error","vue/no-static-inline-styles":"error","vue/no-template-target-blank":"error","vue/no-this-in-before-route-enter":"error","vue/no-undef-components":"off","vue/no-undef-properties":"error","vue/no-unsupported-features":"off","vue/no-unused-emit-declarations":"error","vue/no-unused-properties":["warn",{groups:["props","data","computed","methods","setup"]}],"vue/no-unused-refs":"error","vue/no-use-v-else-with-v-for":"error","vue/no-useless-mustaches":"error","vue/no-useless-v-bind":"error","vue/no-v-text":"error","vue/padding-line-between-blocks":"error","vue/padding-line-between-tags":["error",[{blankLine:"never",prev:"*",next:"*"}]],"vue/padding-lines-in-component-definition":["error",{betweenOptions:"never"}],"vue/prefer-define-options":"error","vue/prefer-prop-type-boolean-first":"error","vue/prefer-separate-static-class":"error","vue/prefer-true-attribute-shorthand":"error","vue/require-direct-export":"error","vue/require-emit-validator":"off","vue/require-explicit-slots":"error","vue/require-expose":"error","vue/require-macro-variable-name":"error","vue/require-name-property":"off","vue/require-prop-comment":"off","vue/require-typed-object-prop":"error","vue/require-typed-ref":"error","vue/script-indent":"off","vue/sort-keys":"off","vue/static-class-names-order":"error","vue/v-for-delimiter-style":"error","vue/v-on-handler-style":"off","vue/valid-define-options":"error","vue/array-bracket-newline":"off","vue/array-bracket-spacing":"off","vue/array-element-newline":"off","vue/arrow-spacing":"off","vue/block-spacing":"off","vue/brace-style":"off","vue/camelcase":"error","vue/comma-dangle":"off","vue/comma-spacing":"off","vue/comma-style":"off","vue/dot-location":"off","vue/dot-notation":"error","vue/eqeqeq":"error","vue/func-call-spacing":"off","vue/key-spacing":"off","vue/keyword-spacing":"off","vue/max-len":"off","vue/multiline-ternary":"off","vue/no-console":"off","vue/no-constant-condition":"error","vue/no-extra-parens":"off","vue/no-empty-pattern":"error","vue/no-irregular-whitespace":"error","vue/no-loss-of-precision":"off","vue/no-restricted-syntax":"off","vue/no-sparse-arrays":"error","vue/no-useless-concat":"error","vue/object-curly-newline":"off","vue/object-curly-spacing":"off","vue/object-property-newline":"off","vue/object-shorthand":"error","vue/operator-linebreak":"off","vue/prefer-template":"error","vue/quote-props":"off","vue/space-in-parens":"off","vue/space-infix-ops":"off","vue/space-unary-ops":"off","vue/template-curly-spacing":"off",...o}}]}function ce(){let e=(0,le.getPackageInfoSync)("vue",{paths:[process.cwd()]});return e&&e.version?+e.version[0]:3}var me=require("eslint-flat-config-utils"),ve=require("@lntvow/utils"),C=require("local-pkg");var Ne=["name","files","ignores","languageOptions","linterOptions","processor","plugins","rules","settings"],Ae={"@stylistic":"style","@typescript-eslint":"typescript","import-x":"import",vitest:"test"};function de(e={},...o){let{autoRenamePlugins:r=!0,componentExts:n=[],gitignore:t=!0,regexp:f=!0,typescript:v=(0,C.isPackageExists)("typescript"),vue:d=["vue","nuxt","vitepress"].some(y=>(0,C.isPackageExists)(y)),test:_=(0,C.isPackageExists)("vitest"),stylistic:c=!0}=e,p=[];p.push(I(),L(),k({...u(e,"javascript")}),B()),t&&p.push(S({...u(e,"gitignore")})),d&&n.push("vue"),v&&p.push(V({...u(e,"typescript"),componentExts:n})),d&&p.push(D({...u(e,"vue")})),f&&p.push(R({...u(e,"regexp")})),_&&p.push(A({...u(e,"test")})),c&&p.push(N({...u(e,"stylistic")}));let $=Ne.reduce((y,T)=>(T in e&&(y[T]=e[T]),y),{});Object.keys($).length&&p.push([$]),p.push(P());let g=new me.FlatConfigComposer;return g=g.append(...p,...o),r&&(g=g.renamePlugins(Ae)),g}function u(e,o){return(0,ve.isBoolean)(e[o])?{}:e[o]||{}}0&&(module.exports={GLOB_ALL_SRC,GLOB_ASTRO,GLOB_CSS,GLOB_EXCLUDE,GLOB_GRAPHQL,GLOB_HTML,GLOB_JS,GLOB_JSON,GLOB_JSON5,GLOB_JSONC,GLOB_JSX,GLOB_LESS,GLOB_MARKDOWN,GLOB_MARKDOWN_CODE,GLOB_MARKDOWN_IN_MARKDOWN,GLOB_POSTCSS,GLOB_SCSS,GLOB_SRC,GLOB_SRC_EXT,GLOB_STYLE,GLOB_SVELTE,GLOB_TESTS,GLOB_TOML,GLOB_TS,GLOB_TSX,GLOB_VUE,GLOB_XML,GLOB_YAML,StylisticConfigDefaults,custom,getVueVersion,gitignore,ignores,imports,javascript,lntvow,prettier,regexp,renameRules,stylistic,test,typescript,vue});
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
+
GLOB_ASTRO: () => GLOB_ASTRO,
|
|
35
|
+
GLOB_CSS: () => GLOB_CSS,
|
|
36
|
+
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
37
|
+
GLOB_GRAPHQL: () => GLOB_GRAPHQL,
|
|
38
|
+
GLOB_HTML: () => GLOB_HTML,
|
|
39
|
+
GLOB_JS: () => GLOB_JS,
|
|
40
|
+
GLOB_JSON: () => GLOB_JSON,
|
|
41
|
+
GLOB_JSON5: () => GLOB_JSON5,
|
|
42
|
+
GLOB_JSONC: () => GLOB_JSONC,
|
|
43
|
+
GLOB_JSX: () => GLOB_JSX,
|
|
44
|
+
GLOB_LESS: () => GLOB_LESS,
|
|
45
|
+
GLOB_MARKDOWN: () => GLOB_MARKDOWN,
|
|
46
|
+
GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
|
|
47
|
+
GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
|
|
48
|
+
GLOB_POSTCSS: () => GLOB_POSTCSS,
|
|
49
|
+
GLOB_SCSS: () => GLOB_SCSS,
|
|
50
|
+
GLOB_SRC: () => GLOB_SRC,
|
|
51
|
+
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
52
|
+
GLOB_STYLE: () => GLOB_STYLE,
|
|
53
|
+
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
54
|
+
GLOB_TESTS: () => GLOB_TESTS,
|
|
55
|
+
GLOB_TOML: () => GLOB_TOML,
|
|
56
|
+
GLOB_TS: () => GLOB_TS,
|
|
57
|
+
GLOB_TSX: () => GLOB_TSX,
|
|
58
|
+
GLOB_VUE: () => GLOB_VUE,
|
|
59
|
+
GLOB_XML: () => GLOB_XML,
|
|
60
|
+
GLOB_YAML: () => GLOB_YAML,
|
|
61
|
+
StylisticConfigDefaults: () => StylisticConfigDefaults,
|
|
62
|
+
custom: () => custom,
|
|
63
|
+
getVueVersion: () => getVueVersion,
|
|
64
|
+
gitignore: () => gitignore,
|
|
65
|
+
ignores: () => ignores,
|
|
66
|
+
imports: () => imports,
|
|
67
|
+
javascript: () => javascript,
|
|
68
|
+
lntvow: () => lntvow,
|
|
69
|
+
prettier: () => prettier,
|
|
70
|
+
regexp: () => regexp,
|
|
71
|
+
renameRules: () => renameRules,
|
|
72
|
+
stylistic: () => stylistic,
|
|
73
|
+
test: () => test,
|
|
74
|
+
typescript: () => typescript,
|
|
75
|
+
vue: () => vue
|
|
76
|
+
});
|
|
77
|
+
module.exports = __toCommonJS(src_exports);
|
|
78
|
+
|
|
79
|
+
// src/utils/index.ts
|
|
80
|
+
function renameRules(rules, map) {
|
|
81
|
+
return Object.fromEntries(
|
|
82
|
+
Object.entries(rules).map(([key, value]) => {
|
|
83
|
+
for (const [from, to] of Object.entries(map)) {
|
|
84
|
+
if (key.startsWith(`${from}/`))
|
|
85
|
+
return [to + key.slice(from.length), value];
|
|
86
|
+
}
|
|
87
|
+
return [key, value];
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/configs/custom.ts
|
|
93
|
+
var import_eslint_plugin = __toESM(require("@lntvow/eslint-plugin"), 1);
|
|
94
|
+
async function custom() {
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
name: "lntvow/custom",
|
|
98
|
+
plugins: {
|
|
99
|
+
lntvow: import_eslint_plugin.default
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/configs/gitignore.ts
|
|
106
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
107
|
+
|
|
108
|
+
// node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
109
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
110
|
+
|
|
111
|
+
// node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
|
|
112
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
113
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
114
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
115
|
+
var import_node_url = require("url");
|
|
116
|
+
var typeMappings = {
|
|
117
|
+
directory: "isDirectory",
|
|
118
|
+
file: "isFile"
|
|
119
|
+
};
|
|
120
|
+
function checkType(type) {
|
|
121
|
+
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`Invalid type specified: ${type}`);
|
|
125
|
+
}
|
|
126
|
+
var matchType = (type, stat) => stat[typeMappings[type]]();
|
|
127
|
+
var toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
128
|
+
function locatePathSync(paths, {
|
|
129
|
+
cwd = import_node_process.default.cwd(),
|
|
130
|
+
type = "file",
|
|
131
|
+
allowSymlinks = true
|
|
132
|
+
} = {}) {
|
|
133
|
+
checkType(type);
|
|
134
|
+
cwd = toPath(cwd);
|
|
135
|
+
const statFunction = allowSymlinks ? import_node_fs.default.statSync : import_node_fs.default.lstatSync;
|
|
136
|
+
for (const path_ of paths) {
|
|
137
|
+
try {
|
|
138
|
+
const stat = statFunction(import_node_path.default.resolve(cwd, path_), {
|
|
139
|
+
throwIfNoEntry: false
|
|
140
|
+
});
|
|
141
|
+
if (!stat) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (matchType(type, stat)) {
|
|
145
|
+
return path_;
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// node_modules/.pnpm/unicorn-magic@0.1.0/node_modules/unicorn-magic/node.js
|
|
153
|
+
var import_node_url2 = require("url");
|
|
154
|
+
function toPath2(urlOrPath) {
|
|
155
|
+
return urlOrPath instanceof URL ? (0, import_node_url2.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
|
|
159
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
160
|
+
|
|
161
|
+
// node_modules/.pnpm/find-up@7.0.0/node_modules/find-up/index.js
|
|
162
|
+
var findUpStop = Symbol("findUpStop");
|
|
163
|
+
function findUpMultipleSync(name, options = {}) {
|
|
164
|
+
let directory = import_node_path2.default.resolve(toPath2(options.cwd) ?? "");
|
|
165
|
+
const { root } = import_node_path2.default.parse(directory);
|
|
166
|
+
const stopAt = import_node_path2.default.resolve(directory, toPath2(options.stopAt) ?? root);
|
|
167
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
168
|
+
const paths = [name].flat();
|
|
169
|
+
const runMatcher = (locateOptions) => {
|
|
170
|
+
if (typeof name !== "function") {
|
|
171
|
+
return locatePathSync(paths, locateOptions);
|
|
172
|
+
}
|
|
173
|
+
const foundPath = name(locateOptions.cwd);
|
|
174
|
+
if (typeof foundPath === "string") {
|
|
175
|
+
return locatePathSync([foundPath], locateOptions);
|
|
176
|
+
}
|
|
177
|
+
return foundPath;
|
|
178
|
+
};
|
|
179
|
+
const matches = [];
|
|
180
|
+
while (true) {
|
|
181
|
+
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
182
|
+
if (foundPath === findUpStop) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
if (foundPath) {
|
|
186
|
+
matches.push(import_node_path2.default.resolve(directory, foundPath));
|
|
187
|
+
}
|
|
188
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
directory = import_node_path2.default.dirname(directory);
|
|
192
|
+
}
|
|
193
|
+
return matches;
|
|
194
|
+
}
|
|
195
|
+
function findUpSync(name, options = {}) {
|
|
196
|
+
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
197
|
+
return matches[0];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/configs/gitignore.ts
|
|
201
|
+
var import_utils = require("@lntvow/utils");
|
|
202
|
+
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
203
|
+
async function gitignore(options) {
|
|
204
|
+
const { name = ".gitignore", root = false, files: _files = root ? name : findUpSync(name) || [] } = options;
|
|
205
|
+
const files = (0, import_utils.castArray)(_files);
|
|
206
|
+
const ignores2 = [];
|
|
207
|
+
for (const file of files) {
|
|
208
|
+
try {
|
|
209
|
+
const content = import_fs.default.readFileSync(file, "utf8");
|
|
210
|
+
const globs = (0, import_parse_gitignore.default)(content).globs();
|
|
211
|
+
for (const glob of globs) {
|
|
212
|
+
if (glob.type === "ignore") {
|
|
213
|
+
ignores2.push(...glob.patterns);
|
|
214
|
+
} else if (glob.type === "unignore") {
|
|
215
|
+
ignores2.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} catch (error) {
|
|
219
|
+
throw new Error(`Failed to read file: ${file}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return [
|
|
223
|
+
{
|
|
224
|
+
ignores: ignores2
|
|
225
|
+
}
|
|
226
|
+
];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/globs.ts
|
|
230
|
+
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
231
|
+
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
232
|
+
var GLOB_JS = "**/*.?([cm])js";
|
|
233
|
+
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
234
|
+
var GLOB_TS = "**/*.?([cm])ts";
|
|
235
|
+
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
236
|
+
var GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
237
|
+
var GLOB_CSS = "**/*.css";
|
|
238
|
+
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
239
|
+
var GLOB_LESS = "**/*.less";
|
|
240
|
+
var GLOB_SCSS = "**/*.scss";
|
|
241
|
+
var GLOB_JSON = "**/*.json";
|
|
242
|
+
var GLOB_JSON5 = "**/*.json5";
|
|
243
|
+
var GLOB_JSONC = "**/*.jsonc";
|
|
244
|
+
var GLOB_MARKDOWN = "**/*.md";
|
|
245
|
+
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
246
|
+
var GLOB_SVELTE = "**/*.svelte";
|
|
247
|
+
var GLOB_VUE = "**/*.vue";
|
|
248
|
+
var GLOB_YAML = "**/*.y?(a)ml";
|
|
249
|
+
var GLOB_TOML = "**/*.toml";
|
|
250
|
+
var GLOB_XML = "**/*.xml";
|
|
251
|
+
var GLOB_HTML = "**/*.htm?(l)";
|
|
252
|
+
var GLOB_ASTRO = "**/*.astro";
|
|
253
|
+
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
254
|
+
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
255
|
+
var GLOB_TESTS = [
|
|
256
|
+
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
257
|
+
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
258
|
+
`**/*.test.${GLOB_SRC_EXT}`,
|
|
259
|
+
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
260
|
+
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
261
|
+
];
|
|
262
|
+
var GLOB_ALL_SRC = [
|
|
263
|
+
GLOB_SRC,
|
|
264
|
+
GLOB_STYLE,
|
|
265
|
+
GLOB_JSON,
|
|
266
|
+
GLOB_JSON5,
|
|
267
|
+
GLOB_MARKDOWN,
|
|
268
|
+
GLOB_SVELTE,
|
|
269
|
+
GLOB_VUE,
|
|
270
|
+
GLOB_YAML,
|
|
271
|
+
GLOB_XML,
|
|
272
|
+
GLOB_HTML
|
|
273
|
+
];
|
|
274
|
+
var GLOB_EXCLUDE = [
|
|
275
|
+
"**/node_modules",
|
|
276
|
+
"**/dist",
|
|
277
|
+
"**/package-lock.json",
|
|
278
|
+
"**/yarn.lock",
|
|
279
|
+
"**/pnpm-lock.yaml",
|
|
280
|
+
"**/bun.lockb",
|
|
281
|
+
"**/output",
|
|
282
|
+
"**/coverage",
|
|
283
|
+
"**/temp",
|
|
284
|
+
"**/.temp",
|
|
285
|
+
"**/tmp",
|
|
286
|
+
"**/.tmp",
|
|
287
|
+
"**/.history",
|
|
288
|
+
"**/.vitepress/cache",
|
|
289
|
+
"**/.nuxt",
|
|
290
|
+
"**/.next",
|
|
291
|
+
"**/.vercel",
|
|
292
|
+
"**/.changeset",
|
|
293
|
+
"**/.idea",
|
|
294
|
+
"**/.cache",
|
|
295
|
+
"**/.output",
|
|
296
|
+
"**/.vite-inspect",
|
|
297
|
+
"**/.yarn",
|
|
298
|
+
"**/CHANGELOG*.md",
|
|
299
|
+
"**/*.min.*",
|
|
300
|
+
"**/LICENSE*",
|
|
301
|
+
"**/__snapshots__",
|
|
302
|
+
"**/auto-import?(s).d.ts",
|
|
303
|
+
"**/components.d.ts"
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
// src/configs/ignores.ts
|
|
307
|
+
async function ignores() {
|
|
308
|
+
return [
|
|
309
|
+
{
|
|
310
|
+
ignores: [...GLOB_EXCLUDE]
|
|
311
|
+
}
|
|
312
|
+
];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// src/configs/imports.ts
|
|
316
|
+
var import_eslint_plugin_import_x = __toESM(require("eslint-plugin-import-x"), 1);
|
|
317
|
+
async function imports() {
|
|
318
|
+
return [
|
|
319
|
+
{
|
|
320
|
+
name: "lntvow/imports/rules",
|
|
321
|
+
plugins: {
|
|
322
|
+
import: import_eslint_plugin_import_x.default
|
|
323
|
+
},
|
|
324
|
+
rules: {
|
|
325
|
+
"import/order": "error",
|
|
326
|
+
"import/newline-after-import": "error"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/configs/javascript.ts
|
|
333
|
+
var import_js = __toESM(require("@eslint/js"), 1);
|
|
334
|
+
var import_globals = __toESM(require("globals"), 1);
|
|
335
|
+
async function javascript(options = {}) {
|
|
336
|
+
const { overrides = {} } = options;
|
|
337
|
+
return [
|
|
338
|
+
{
|
|
339
|
+
name: "lntvow/javascript/rules",
|
|
340
|
+
languageOptions: {
|
|
341
|
+
ecmaVersion: 2022,
|
|
342
|
+
sourceType: "module",
|
|
343
|
+
parserOptions: {
|
|
344
|
+
ecmaVersion: 2022,
|
|
345
|
+
sourceType: "module",
|
|
346
|
+
ecmaFeatures: {
|
|
347
|
+
jsx: true
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
globals: {
|
|
351
|
+
...import_globals.default.browser,
|
|
352
|
+
...import_globals.default.es2021,
|
|
353
|
+
...import_globals.default.node,
|
|
354
|
+
document: "readonly",
|
|
355
|
+
navigator: "readonly",
|
|
356
|
+
window: "readonly"
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
linterOptions: {
|
|
360
|
+
reportUnusedDisableDirectives: true
|
|
361
|
+
},
|
|
362
|
+
rules: {
|
|
363
|
+
// Update to eslint-plugin-vue v9.3.0
|
|
364
|
+
...import_js.default.configs.all.rules,
|
|
365
|
+
// 禁止未使用过的变量
|
|
366
|
+
"no-unused-vars": "warn",
|
|
367
|
+
// 禁止定义前使用
|
|
368
|
+
"no-use-before-define": ["error", { functions: false, variables: false }],
|
|
369
|
+
// 禁止无用的分配 有时候需要置空变量时候需要用到
|
|
370
|
+
"no-useless-assignment": "off",
|
|
371
|
+
// 禁止使用 await 或 yield 导致竞争条件的分配
|
|
372
|
+
"require-atomic-updates": "off",
|
|
373
|
+
// 强制使用骆驼拼写法命名约定
|
|
374
|
+
"camelcase": "warn",
|
|
375
|
+
// 强制注释首字母大写或小写
|
|
376
|
+
"capitalized-comments": "off",
|
|
377
|
+
// 强制类方法使用this
|
|
378
|
+
"class-methods-use-this": "off",
|
|
379
|
+
// 指定程序中允许的最大环路复杂度
|
|
380
|
+
"complexity": "off",
|
|
381
|
+
// 强制保证多行所有的花括号,
|
|
382
|
+
"curly": ["error", "multi-line"],
|
|
383
|
+
// 要求使用命名的 function 表达式 便于调试
|
|
384
|
+
"func-names": "off",
|
|
385
|
+
// 强制一致地使用 function 声明或表达式
|
|
386
|
+
"func-style": "off",
|
|
387
|
+
// 要求 for-in 循环中有一个 if 语句
|
|
388
|
+
"guard-for-in": "off",
|
|
389
|
+
// 禁用指定的标识符
|
|
390
|
+
"id-denylist": "off",
|
|
391
|
+
// 强制标识符的最小和最大长度
|
|
392
|
+
"id-length": "off",
|
|
393
|
+
// 禁止使用指定的标识符
|
|
394
|
+
"id-match": "off",
|
|
395
|
+
// 要求变量声明并同时初始化
|
|
396
|
+
"init-declarations": "off",
|
|
397
|
+
// 强制每个文件中包含的的类的最大数量
|
|
398
|
+
"max-classes-per-file": "off",
|
|
399
|
+
// 强制可嵌套的块的最大深度
|
|
400
|
+
"max-depth": "off",
|
|
401
|
+
// 强制最大行数
|
|
402
|
+
"max-lines": "off",
|
|
403
|
+
// 强制函数最大行数
|
|
404
|
+
"max-lines-per-function": "off",
|
|
405
|
+
// 强制回调函数最大嵌套深度
|
|
406
|
+
"max-nested-callbacks": "off",
|
|
407
|
+
// 强制函数定义中最多允许的参数数量
|
|
408
|
+
"max-params": "off",
|
|
409
|
+
// 强制函数块最多允许的的语句数量
|
|
410
|
+
"max-statements": "off",
|
|
411
|
+
// 要求构造函数首字母大写
|
|
412
|
+
"new-cap": ["error", { capIsNew: false }],
|
|
413
|
+
// 禁止使用按位操作符
|
|
414
|
+
"no-bitwise": "off",
|
|
415
|
+
// 禁止在 case 或 default 子句中出现词法声明
|
|
416
|
+
"no-case-declarations": "off",
|
|
417
|
+
// 禁止使用 console
|
|
418
|
+
"no-console": "warn",
|
|
419
|
+
// 禁用 continue 语句
|
|
420
|
+
"no-continue": "off",
|
|
421
|
+
// 禁止空块语句
|
|
422
|
+
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
423
|
+
// 禁止使用短符号进行类型转换
|
|
424
|
+
"no-implicit-coercion": "off",
|
|
425
|
+
// 禁止在全局范围内使用变量声明和 function 声明
|
|
426
|
+
"no-implicit-globals": "off",
|
|
427
|
+
// 禁用魔术数字
|
|
428
|
+
"no-magic-numbers": 0,
|
|
429
|
+
// 禁用嵌套的三元表达式
|
|
430
|
+
"no-nested-ternary": "off",
|
|
431
|
+
// 禁止空 new 以避免产生副作用
|
|
432
|
+
"no-new": "off",
|
|
433
|
+
// 禁止对 function 的参数进行重新赋值
|
|
434
|
+
"no-param-reassign": "off",
|
|
435
|
+
// 禁用一元操作符 ++ 和 --
|
|
436
|
+
"no-plusplus": "off",
|
|
437
|
+
// 禁用特定导出名称
|
|
438
|
+
"no-restricted-exports": "off",
|
|
439
|
+
// 禁用特定的全局变量
|
|
440
|
+
"no-restricted-globals": [
|
|
441
|
+
"error",
|
|
442
|
+
{ message: "Use `globalThis` instead.", name: "global" },
|
|
443
|
+
{ message: "Use `globalThis` instead.", name: "self" }
|
|
444
|
+
],
|
|
445
|
+
// 禁用特定的导入
|
|
446
|
+
"no-restricted-imports": "off",
|
|
447
|
+
// 禁止使用对象的某些属性
|
|
448
|
+
"no-restricted-properties": [
|
|
449
|
+
"error",
|
|
450
|
+
{ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
|
|
451
|
+
{ message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
|
|
452
|
+
{ message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
|
|
453
|
+
{ message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
|
|
454
|
+
{ message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
|
|
455
|
+
],
|
|
456
|
+
// 禁用特定的语法
|
|
457
|
+
"no-restricted-syntax": "off",
|
|
458
|
+
// 禁止变量声明与外层作用域的变量同名
|
|
459
|
+
"no-shadow": "off",
|
|
460
|
+
// 禁用三元操作符
|
|
461
|
+
"no-ternary": "off",
|
|
462
|
+
// 禁止抛出异常字面量
|
|
463
|
+
"no-throw-literal": "off",
|
|
464
|
+
// 禁用undefined
|
|
465
|
+
"no-undefined": "off",
|
|
466
|
+
// 禁止标识符中有下划线
|
|
467
|
+
"no-underscore-dangle": "off",
|
|
468
|
+
// 禁用 void 操作符
|
|
469
|
+
"no-void": "off",
|
|
470
|
+
// 禁止在注释中使用特定的警告术语
|
|
471
|
+
"no-warning-comments": "off",
|
|
472
|
+
// 强制函数中的变量在一起声明
|
|
473
|
+
"one-var": "off",
|
|
474
|
+
// 禁止使用 Math.pow 幂运算符
|
|
475
|
+
"prefer-exponentiation-operator": "off",
|
|
476
|
+
// 要求使用 Error 对象作为 Promise 拒绝的原因
|
|
477
|
+
"prefer-promise-reject-errors": "off",
|
|
478
|
+
// 强制在parseInt()使用基数参数
|
|
479
|
+
"radix": "off",
|
|
480
|
+
// 禁止使用不带 await 表达式的 async 函数
|
|
481
|
+
"require-await": "off",
|
|
482
|
+
// 强制在RegExp上使用u标志
|
|
483
|
+
"require-unicode-regexp": "off",
|
|
484
|
+
// imports排序 不好用
|
|
485
|
+
"sort-imports": "off",
|
|
486
|
+
// 要求对象属性按序排列
|
|
487
|
+
"sort-keys": "off",
|
|
488
|
+
// 要求同一个声明块中的变量按顺序排列
|
|
489
|
+
"sort-vars": "off",
|
|
490
|
+
// 要求或禁止使用严格模式指令
|
|
491
|
+
"strict": "off",
|
|
492
|
+
// Overrides
|
|
493
|
+
...overrides
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
files: [`scripts/${GLOB_SRC}`],
|
|
498
|
+
name: "lntvow/javascript/disables",
|
|
499
|
+
rules: {
|
|
500
|
+
"no-console": "off"
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// src/configs/prettier.ts
|
|
507
|
+
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
508
|
+
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
509
|
+
async function prettier() {
|
|
510
|
+
return [
|
|
511
|
+
{
|
|
512
|
+
name: "lntvow/prettier/rules",
|
|
513
|
+
plugins: {
|
|
514
|
+
prettier: import_eslint_plugin_prettier.default
|
|
515
|
+
},
|
|
516
|
+
rules: {
|
|
517
|
+
...import_eslint_config_prettier.default.rules,
|
|
518
|
+
"prettier/prettier": "warn"
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
];
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// src/configs/regexp.ts
|
|
525
|
+
var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
526
|
+
async function regexp(options = {}) {
|
|
527
|
+
const { overrides } = options;
|
|
528
|
+
const pluginRegexp = import_eslint_plugin_regexp.configs["flat/recommended"].plugins.regexp;
|
|
529
|
+
const { rules } = import_eslint_plugin_regexp.configs["flat/recommended"];
|
|
530
|
+
return [
|
|
531
|
+
{
|
|
532
|
+
name: "lntvow/regexp/rules",
|
|
533
|
+
plugins: {
|
|
534
|
+
regexp: pluginRegexp
|
|
535
|
+
},
|
|
536
|
+
rules: {
|
|
537
|
+
// Update to eslint-plugin-regexp v2.6.0
|
|
538
|
+
...rules,
|
|
539
|
+
// Overrides
|
|
540
|
+
...overrides
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
];
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/configs/stylistic.ts
|
|
547
|
+
var import_eslint_plugin2 = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
548
|
+
var StylisticConfigDefaults = {
|
|
549
|
+
indent: 2,
|
|
550
|
+
jsx: true,
|
|
551
|
+
quotes: "single",
|
|
552
|
+
semi: false
|
|
553
|
+
};
|
|
554
|
+
async function stylistic(options = {}) {
|
|
555
|
+
const {
|
|
556
|
+
indent,
|
|
557
|
+
jsx,
|
|
558
|
+
overrides = {},
|
|
559
|
+
quotes,
|
|
560
|
+
semi
|
|
561
|
+
} = {
|
|
562
|
+
...StylisticConfigDefaults,
|
|
563
|
+
...options
|
|
564
|
+
};
|
|
565
|
+
const config = import_eslint_plugin2.default.configs.customize({
|
|
566
|
+
flat: true,
|
|
567
|
+
indent,
|
|
568
|
+
jsx,
|
|
569
|
+
pluginName: "style",
|
|
570
|
+
quotes,
|
|
571
|
+
semi
|
|
572
|
+
});
|
|
573
|
+
return [
|
|
574
|
+
{
|
|
575
|
+
name: "lntvow/stylistic/rules",
|
|
576
|
+
plugins: {
|
|
577
|
+
style: import_eslint_plugin2.default
|
|
578
|
+
},
|
|
579
|
+
rules: {
|
|
580
|
+
// ...config.rules,
|
|
581
|
+
// Custom rules
|
|
582
|
+
"style/spaced-comment": "error",
|
|
583
|
+
"style/padding-line-between-statements": [
|
|
584
|
+
"error",
|
|
585
|
+
{ blankLine: "always", prev: "*", next: "cjs-export" },
|
|
586
|
+
{ blankLine: "always", prev: "*", next: "export" },
|
|
587
|
+
{ blankLine: "always", prev: "*", next: "function" }
|
|
588
|
+
],
|
|
589
|
+
// overrides
|
|
590
|
+
...overrides
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
];
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// src/configs/test.ts
|
|
597
|
+
var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
|
|
598
|
+
async function test(options = {}) {
|
|
599
|
+
const { overrides } = options;
|
|
600
|
+
return [
|
|
601
|
+
{
|
|
602
|
+
name: "lntvow/test/setup",
|
|
603
|
+
plugins: {
|
|
604
|
+
test: import_eslint_plugin_vitest.default
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: "lntvow/test/rules",
|
|
609
|
+
files: [...GLOB_TESTS],
|
|
610
|
+
rules: {
|
|
611
|
+
"lntvow/newline-before-describe-test": "error",
|
|
612
|
+
// Overrides
|
|
613
|
+
...overrides
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
];
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/configs/typescript.ts
|
|
620
|
+
var import_eslint_plugin3 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
|
|
621
|
+
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
622
|
+
async function typescript(options = {}) {
|
|
623
|
+
const { componentExts = [], overrides = {}, parserOptions = {} } = options;
|
|
624
|
+
const files = [GLOB_SRC, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
625
|
+
return [
|
|
626
|
+
{
|
|
627
|
+
name: "lntvow/typescript/setup",
|
|
628
|
+
plugins: {
|
|
629
|
+
ts: import_eslint_plugin3.default
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
name: "lntvow/typescript/rules",
|
|
634
|
+
languageOptions: {
|
|
635
|
+
parser: import_parser.default,
|
|
636
|
+
parserOptions: {
|
|
637
|
+
sourceType: "module"
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
files,
|
|
641
|
+
rules: {
|
|
642
|
+
...renameRules(import_eslint_plugin3.default.configs["eslint-recommended"].overrides[0].rules, {
|
|
643
|
+
"@typescript-eslint": "ts"
|
|
644
|
+
}),
|
|
645
|
+
...renameRules(import_eslint_plugin3.default.configs.strict.rules, { "@typescript-eslint": "ts" }),
|
|
646
|
+
// Override default configuration
|
|
647
|
+
// 禁止使用!断言
|
|
648
|
+
"ts/no-non-null-assertion": "off",
|
|
649
|
+
// 禁止使用any
|
|
650
|
+
"ts/no-explicit-any": "off",
|
|
651
|
+
// 禁止使用ts注释
|
|
652
|
+
"ts/ban-ts-comment": "off",
|
|
653
|
+
// 未使用的变量
|
|
654
|
+
"ts/no-unused-vars": "warn",
|
|
655
|
+
// Override javascript configuration
|
|
656
|
+
"no-use-before-define": "off",
|
|
657
|
+
"ts/no-use-before-define": ["error", { functions: false, variables: false }],
|
|
658
|
+
// Overrides
|
|
659
|
+
...overrides
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
];
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// src/configs/vue.ts
|
|
666
|
+
var import_local_pkg = require("local-pkg");
|
|
667
|
+
var import_parser2 = __toESM(require("@typescript-eslint/parser"), 1);
|
|
668
|
+
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
669
|
+
var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
|
|
670
|
+
async function vue(options = {}) {
|
|
671
|
+
const { overrides = {}, vueVersion = getVueVersion() } = options;
|
|
672
|
+
const vue3Rules = {
|
|
673
|
+
...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
|
|
674
|
+
...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
|
|
675
|
+
...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules,
|
|
676
|
+
"vue/block-lang": ["error", { script: { lang: ["ts", "tsx"] } }],
|
|
677
|
+
"vue/block-order": ["error", { order: ["script[setup]", "template", "style[scoped]"] }],
|
|
678
|
+
"vue/component-api-style": "error"
|
|
679
|
+
};
|
|
680
|
+
const vue2Rules = {
|
|
681
|
+
...import_eslint_plugin_vue.default.configs.essential.rules,
|
|
682
|
+
...import_eslint_plugin_vue.default.configs["strongly-recommended"].rules,
|
|
683
|
+
...import_eslint_plugin_vue.default.configs.recommended.rules,
|
|
684
|
+
"vue/block-lang": ["error", { script: { allowNoLang: true } }],
|
|
685
|
+
"vue/block-order": ["error", { order: [["script", "template"], "style[scoped]"] }]
|
|
686
|
+
};
|
|
687
|
+
return [
|
|
688
|
+
{
|
|
689
|
+
name: "lntvow/vue/setup",
|
|
690
|
+
plugins: {
|
|
691
|
+
vue: import_eslint_plugin_vue.default
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "lntvow/vue/rules",
|
|
696
|
+
languageOptions: {
|
|
697
|
+
parser: import_vue_eslint_parser.default,
|
|
698
|
+
parserOptions: {
|
|
699
|
+
ecmaFeatures: {
|
|
700
|
+
jsx: true
|
|
701
|
+
},
|
|
702
|
+
parser: {
|
|
703
|
+
ts: import_parser2.default,
|
|
704
|
+
tsx: import_parser2.default
|
|
705
|
+
},
|
|
706
|
+
sourceType: "module"
|
|
707
|
+
}
|
|
708
|
+
// globals: {
|
|
709
|
+
// computed: 'readonly',
|
|
710
|
+
// defineEmits: 'readonly',
|
|
711
|
+
// defineExpose: 'readonly',
|
|
712
|
+
// defineProps: 'readonly',
|
|
713
|
+
// onMounted: 'readonly',
|
|
714
|
+
// onUnmounted: 'readonly',
|
|
715
|
+
// reactive: 'readonly',
|
|
716
|
+
// ref: 'readonly',
|
|
717
|
+
// shallowReactive: 'readonly',
|
|
718
|
+
// shallowRef: 'readonly',
|
|
719
|
+
// toRef: 'readonly',
|
|
720
|
+
// toRefs: 'readonly',
|
|
721
|
+
// watch: 'readonly',
|
|
722
|
+
// watchEffect: 'readonly',
|
|
723
|
+
// },
|
|
724
|
+
},
|
|
725
|
+
processor: import_eslint_plugin_vue.default.processors[".vue"],
|
|
726
|
+
files: [GLOB_VUE],
|
|
727
|
+
rules: {
|
|
728
|
+
// Update to eslint-plugin-vue v9.26.0
|
|
729
|
+
...import_eslint_plugin_vue.default.configs.base.rules,
|
|
730
|
+
...vueVersion === 3 ? vue3Rules : vue2Rules,
|
|
731
|
+
// Override default configuration
|
|
732
|
+
// vue禁用多个单词组件名
|
|
733
|
+
"vue/multi-word-component-names": "off",
|
|
734
|
+
// vue禁用 属性-连接 个人喜欢驼峰
|
|
735
|
+
"vue/attribute-hyphenation": ["error", "never"],
|
|
736
|
+
// vue禁用标签缩进
|
|
737
|
+
"vue/html-indent": "off",
|
|
738
|
+
// 标签自闭合
|
|
739
|
+
"vue/html-self-closing": [
|
|
740
|
+
"error",
|
|
741
|
+
{
|
|
742
|
+
html: { void: "always", normal: "always", component: "always" },
|
|
743
|
+
svg: "always",
|
|
744
|
+
math: "always"
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
// vue禁用标签属性换行
|
|
748
|
+
"vue/max-attributes-per-line": "off",
|
|
749
|
+
// vue内容强制换行
|
|
750
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
751
|
+
// 禁用事件驼峰 个人喜欢驼峰
|
|
752
|
+
"vue/v-on-event-hyphenation": ["error", "never"],
|
|
753
|
+
// Custom rules
|
|
754
|
+
// 标签换行
|
|
755
|
+
"vue/block-tag-newline": "error",
|
|
756
|
+
// 强制模板组件名称为PascalCase
|
|
757
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase", { ignores: ["/-/"] }],
|
|
758
|
+
// 强制组件名大驼峰
|
|
759
|
+
"vue/component-options-name-casing": "error",
|
|
760
|
+
// 强制事件名小驼峰
|
|
761
|
+
"vue/custom-event-name-casing": "error",
|
|
762
|
+
// 强制定义emits
|
|
763
|
+
"vue/define-emits-declaration": "error",
|
|
764
|
+
// 强制定义宏defineProps defineEmits的顺序
|
|
765
|
+
"vue/define-macros-order": "error",
|
|
766
|
+
// 强制定义props
|
|
767
|
+
"vue/define-props-declaration": "error",
|
|
768
|
+
// 强制style属性
|
|
769
|
+
"vue/enforce-style-attribute": "error",
|
|
770
|
+
// 禁止button没有type
|
|
771
|
+
"vue/html-button-has-type": "off",
|
|
772
|
+
// 强制html注释换行
|
|
773
|
+
"vue/html-comment-content-newline": "error",
|
|
774
|
+
// 强制html注释空格
|
|
775
|
+
"vue/html-comment-content-spacing": "error",
|
|
776
|
+
// 强制html注释缩进
|
|
777
|
+
"vue/html-comment-indent": "off",
|
|
778
|
+
// 强制组件名和文件名一致
|
|
779
|
+
"vue/match-component-file-name": ["error", { extensions: ["jsx", "tsx"], shouldMatchCase: true }],
|
|
780
|
+
// 强制组件名导入名称一致
|
|
781
|
+
"vue/match-component-import-name": "error",
|
|
782
|
+
// 强制单个标签最大行数
|
|
783
|
+
"vue/max-lines-per-block": "off",
|
|
784
|
+
// 强制多行属性空行
|
|
785
|
+
"vue/new-line-between-multi-line-property": "off",
|
|
786
|
+
// 强制nextTick风格
|
|
787
|
+
"vue/next-tick-style": "off",
|
|
788
|
+
// 禁止模板中出现未翻译的字符串
|
|
789
|
+
"vue/no-bare-strings-in-template": "off",
|
|
790
|
+
// 布尔类型默认值校验
|
|
791
|
+
"vue/no-boolean-default": "off",
|
|
792
|
+
// 禁止使用已弃用的v-model定义
|
|
793
|
+
"vue/no-deprecated-model-definition": "error",
|
|
794
|
+
// 禁止重复继承属性
|
|
795
|
+
"vue/no-duplicate-attr-inheritance": "error",
|
|
796
|
+
// 禁止空的标签
|
|
797
|
+
"vue/no-empty-component-block": "off",
|
|
798
|
+
// 禁止class 中出现多个对象
|
|
799
|
+
"vue/no-multiple-objects-in-class": "error",
|
|
800
|
+
// 禁止潜在的组件选项拼写错误
|
|
801
|
+
"vue/no-potential-component-option-typo": "error",
|
|
802
|
+
// 禁止ref对象丢失响应性
|
|
803
|
+
"vue/no-ref-object-reactivity-loss": "error",
|
|
804
|
+
// 禁止default和required同时存在
|
|
805
|
+
"vue/no-required-prop-with-default": "error",
|
|
806
|
+
// 禁止特定的模板语法
|
|
807
|
+
"vue/no-restricted-block": "off",
|
|
808
|
+
// 禁止await后调用特定的函数
|
|
809
|
+
"vue/no-restricted-call-after-await": "off",
|
|
810
|
+
// 禁止特定的class
|
|
811
|
+
"vue/no-restricted-class": "off",
|
|
812
|
+
// 禁止特定的组件名
|
|
813
|
+
"vue/no-restricted-component-names": "off",
|
|
814
|
+
// 禁止特定的组件选项
|
|
815
|
+
"vue/no-restricted-component-options": "off",
|
|
816
|
+
// 禁止特定的事件名
|
|
817
|
+
"vue/no-restricted-custom-event": "off",
|
|
818
|
+
// 禁止特定的html标签
|
|
819
|
+
"vue/no-restricted-html-elements": "off",
|
|
820
|
+
// 禁止特定的props
|
|
821
|
+
"vue/no-restricted-props": "off",
|
|
822
|
+
// 禁止特定的静态属性
|
|
823
|
+
"vue/no-restricted-static-attribute": "off",
|
|
824
|
+
// 禁止特定的v-bind
|
|
825
|
+
"vue/no-restricted-v-bind": "off",
|
|
826
|
+
// 禁止根元素使用v-if
|
|
827
|
+
"vue/no-root-v-if": "off",
|
|
828
|
+
// 禁止setup中props丢失响应性
|
|
829
|
+
"vue/no-setup-props-reactivity-loss": "error",
|
|
830
|
+
// 禁止内联样式
|
|
831
|
+
"vue/no-static-inline-styles": "error",
|
|
832
|
+
// 禁止target="_blank"
|
|
833
|
+
"vue/no-template-target-blank": "error",
|
|
834
|
+
// 禁止在beforeRouteEnter中使用this
|
|
835
|
+
"vue/no-this-in-before-route-enter": "error",
|
|
836
|
+
// 禁止未定义的组件
|
|
837
|
+
"vue/no-undef-components": "off",
|
|
838
|
+
// 禁止未定义的属性 mixin vuex冲突
|
|
839
|
+
"vue/no-undef-properties": "error",
|
|
840
|
+
// 禁止不支持的特性
|
|
841
|
+
"vue/no-unsupported-features": "off",
|
|
842
|
+
// 禁止未使用的emits
|
|
843
|
+
"vue/no-unused-emit-declarations": "error",
|
|
844
|
+
// 未使用属性校验
|
|
845
|
+
"vue/no-unused-properties": ["warn", { groups: ["props", "data", "computed", "methods", "setup"] }],
|
|
846
|
+
// 禁止未使用属性ref
|
|
847
|
+
"vue/no-unused-refs": "error",
|
|
848
|
+
// 禁止v-else和v-for同时使用
|
|
849
|
+
"vue/no-use-v-else-with-v-for": "error",
|
|
850
|
+
// 禁止使用无效的模板语法
|
|
851
|
+
"vue/no-useless-mustaches": "error",
|
|
852
|
+
// v-bind强制简写
|
|
853
|
+
"vue/no-useless-v-bind": "error",
|
|
854
|
+
// 禁止使用v-text
|
|
855
|
+
"vue/no-v-text": "error",
|
|
856
|
+
// 模板三标签之间强制空一行
|
|
857
|
+
"vue/padding-line-between-blocks": "error",
|
|
858
|
+
// 禁止模板空行
|
|
859
|
+
"vue/padding-line-between-tags": ["error", [{ blankLine: "never", prev: "*", next: "*" }]],
|
|
860
|
+
// 组件定义强制空行
|
|
861
|
+
"vue/padding-lines-in-component-definition": ["error", { betweenOptions: "never" }],
|
|
862
|
+
// 宏定义选项强制
|
|
863
|
+
"vue/prefer-define-options": "error",
|
|
864
|
+
// props强制boolean类型在前
|
|
865
|
+
"vue/prefer-prop-type-boolean-first": "error",
|
|
866
|
+
// 要求模板中的静态类名位于单独的class属性中
|
|
867
|
+
"vue/prefer-separate-static-class": "error",
|
|
868
|
+
// props 强制true简写
|
|
869
|
+
"vue/prefer-true-attribute-shorthand": "error",
|
|
870
|
+
// 要求组件直接导出
|
|
871
|
+
"vue/require-direct-export": "error",
|
|
872
|
+
// 要求emit事件校验
|
|
873
|
+
"vue/require-emit-validator": "off",
|
|
874
|
+
// 要求明确的插槽
|
|
875
|
+
"vue/require-explicit-slots": "error",
|
|
876
|
+
// 强制expose
|
|
877
|
+
"vue/require-expose": "error",
|
|
878
|
+
// 宏定义变量名强制
|
|
879
|
+
"vue/require-macro-variable-name": "error",
|
|
880
|
+
// 强制name属性
|
|
881
|
+
"vue/require-name-property": "off",
|
|
882
|
+
// 强制prop注释
|
|
883
|
+
"vue/require-prop-comment": "off",
|
|
884
|
+
// 强制对象类型
|
|
885
|
+
"vue/require-typed-object-prop": "error",
|
|
886
|
+
// 强制ref类型
|
|
887
|
+
"vue/require-typed-ref": "error",
|
|
888
|
+
// script缩进
|
|
889
|
+
"vue/script-indent": "off",
|
|
890
|
+
// 强制属性排序
|
|
891
|
+
"vue/sort-keys": "off",
|
|
892
|
+
// class排序
|
|
893
|
+
"vue/static-class-names-order": "error",
|
|
894
|
+
// 强制v-for指令的分隔符样式
|
|
895
|
+
"vue/v-for-delimiter-style": "error",
|
|
896
|
+
// 强制v-on指令的风格
|
|
897
|
+
"vue/v-on-handler-style": "off",
|
|
898
|
+
// 宏定义选项校验
|
|
899
|
+
"vue/valid-define-options": "error",
|
|
900
|
+
// Stylistic
|
|
901
|
+
"vue/array-bracket-newline": "off",
|
|
902
|
+
"vue/array-bracket-spacing": "off",
|
|
903
|
+
"vue/array-element-newline": "off",
|
|
904
|
+
"vue/arrow-spacing": "off",
|
|
905
|
+
"vue/block-spacing": "off",
|
|
906
|
+
"vue/brace-style": "off",
|
|
907
|
+
// 强制驼峰
|
|
908
|
+
"vue/camelcase": "error",
|
|
909
|
+
"vue/comma-dangle": "off",
|
|
910
|
+
"vue/comma-spacing": "off",
|
|
911
|
+
"vue/comma-style": "off",
|
|
912
|
+
"vue/dot-location": "off",
|
|
913
|
+
// 要求使用点号
|
|
914
|
+
"vue/dot-notation": "error",
|
|
915
|
+
// 要求使用 === 和 !==
|
|
916
|
+
"vue/eqeqeq": "error",
|
|
917
|
+
"vue/func-call-spacing": "off",
|
|
918
|
+
"vue/key-spacing": "off",
|
|
919
|
+
"vue/keyword-spacing": "off",
|
|
920
|
+
"vue/max-len": "off",
|
|
921
|
+
"vue/multiline-ternary": "off",
|
|
922
|
+
"vue/no-console": "off",
|
|
923
|
+
// 禁止在条件中使用常量表达式
|
|
924
|
+
"vue/no-constant-condition": "error",
|
|
925
|
+
"vue/no-extra-parens": "off",
|
|
926
|
+
// 禁止使用空解构模式
|
|
927
|
+
"vue/no-empty-pattern": "error",
|
|
928
|
+
// 禁止不规则的空白
|
|
929
|
+
"vue/no-irregular-whitespace": "error",
|
|
930
|
+
"vue/no-loss-of-precision": "off",
|
|
931
|
+
"vue/no-restricted-syntax": "off",
|
|
932
|
+
// 禁用稀疏数组
|
|
933
|
+
"vue/no-sparse-arrays": "error",
|
|
934
|
+
// 禁止没有必要的字符拼接
|
|
935
|
+
"vue/no-useless-concat": "error",
|
|
936
|
+
"vue/object-curly-newline": "off",
|
|
937
|
+
"vue/object-curly-spacing": "off",
|
|
938
|
+
"vue/object-property-newline": "off",
|
|
939
|
+
// 要求对象字面量简写语法
|
|
940
|
+
"vue/object-shorthand": "error",
|
|
941
|
+
"vue/operator-linebreak": "off",
|
|
942
|
+
// 优先使用模板字符串
|
|
943
|
+
"vue/prefer-template": "error",
|
|
944
|
+
"vue/quote-props": "off",
|
|
945
|
+
"vue/space-in-parens": "off",
|
|
946
|
+
"vue/space-infix-ops": "off",
|
|
947
|
+
"vue/space-unary-ops": "off",
|
|
948
|
+
"vue/template-curly-spacing": "off",
|
|
949
|
+
// Overrides
|
|
950
|
+
...overrides
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
];
|
|
954
|
+
}
|
|
955
|
+
function getVueVersion() {
|
|
956
|
+
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [process.cwd()] });
|
|
957
|
+
if (pkg && pkg.version) {
|
|
958
|
+
return +pkg.version[0];
|
|
959
|
+
}
|
|
960
|
+
return 3;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// src/factory.ts
|
|
964
|
+
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
965
|
+
var import_utils3 = require("@lntvow/utils");
|
|
966
|
+
var import_local_pkg2 = require("local-pkg");
|
|
967
|
+
var flatConfigProps = [
|
|
968
|
+
"name",
|
|
969
|
+
"files",
|
|
970
|
+
"ignores",
|
|
971
|
+
"languageOptions",
|
|
972
|
+
"linterOptions",
|
|
973
|
+
"processor",
|
|
974
|
+
"plugins",
|
|
975
|
+
"rules",
|
|
976
|
+
"settings"
|
|
977
|
+
];
|
|
978
|
+
var defaultPluginRenaming = {
|
|
979
|
+
"@stylistic": "style",
|
|
980
|
+
"@typescript-eslint": "typescript",
|
|
981
|
+
"import-x": "import",
|
|
982
|
+
"vitest": "test"
|
|
983
|
+
};
|
|
984
|
+
function lntvow(options = {}, ...userConfigs) {
|
|
985
|
+
const {
|
|
986
|
+
autoRenamePlugins = true,
|
|
987
|
+
componentExts = [],
|
|
988
|
+
gitignore: enableGitignore = true,
|
|
989
|
+
regexp: enableRegexp = true,
|
|
990
|
+
typescript: enableTypeScript = (0, import_local_pkg2.isPackageExists)("typescript"),
|
|
991
|
+
vue: enableVue = ["vue", "nuxt", "vitepress"].some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
992
|
+
test: enableTest = (0, import_local_pkg2.isPackageExists)("vitest"),
|
|
993
|
+
stylistic: enableStylistic = true
|
|
994
|
+
} = options;
|
|
995
|
+
const configs2 = [];
|
|
996
|
+
configs2.push(
|
|
997
|
+
ignores(),
|
|
998
|
+
custom(),
|
|
999
|
+
javascript({
|
|
1000
|
+
...resolveSubOptions(options, "javascript")
|
|
1001
|
+
}),
|
|
1002
|
+
imports()
|
|
1003
|
+
// comments(),
|
|
1004
|
+
// node(),
|
|
1005
|
+
// jsdoc({
|
|
1006
|
+
// stylistic: stylisticOptions,
|
|
1007
|
+
// }),
|
|
1008
|
+
// unicorn(),
|
|
1009
|
+
// command(),
|
|
1010
|
+
// Optional plugins (installed but not enabled by default)
|
|
1011
|
+
// perfectionist(),
|
|
1012
|
+
);
|
|
1013
|
+
if (enableGitignore) {
|
|
1014
|
+
configs2.push(gitignore({ ...resolveSubOptions(options, "gitignore") }));
|
|
1015
|
+
}
|
|
1016
|
+
if (enableVue) {
|
|
1017
|
+
componentExts.push("vue");
|
|
1018
|
+
}
|
|
1019
|
+
if (enableTypeScript) {
|
|
1020
|
+
configs2.push(typescript({ ...resolveSubOptions(options, "typescript"), componentExts }));
|
|
1021
|
+
}
|
|
1022
|
+
if (enableVue) {
|
|
1023
|
+
configs2.push(vue({ ...resolveSubOptions(options, "vue") }));
|
|
1024
|
+
}
|
|
1025
|
+
if (enableRegexp) {
|
|
1026
|
+
configs2.push(regexp({ ...resolveSubOptions(options, "regexp") }));
|
|
1027
|
+
}
|
|
1028
|
+
if (enableTest) {
|
|
1029
|
+
configs2.push(test({ ...resolveSubOptions(options, "test") }));
|
|
1030
|
+
}
|
|
1031
|
+
if (enableStylistic) {
|
|
1032
|
+
configs2.push(stylistic({ ...resolveSubOptions(options, "stylistic") }));
|
|
1033
|
+
}
|
|
1034
|
+
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1035
|
+
if (key in options) {
|
|
1036
|
+
acc[key] = options[key];
|
|
1037
|
+
}
|
|
1038
|
+
return acc;
|
|
1039
|
+
}, {});
|
|
1040
|
+
if (Object.keys(fusedConfig).length) {
|
|
1041
|
+
configs2.push([fusedConfig]);
|
|
1042
|
+
}
|
|
1043
|
+
configs2.push(prettier());
|
|
1044
|
+
let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
1045
|
+
composer = composer.append(...configs2, ...userConfigs);
|
|
1046
|
+
if (autoRenamePlugins) {
|
|
1047
|
+
composer = composer.renamePlugins(defaultPluginRenaming);
|
|
1048
|
+
}
|
|
1049
|
+
return composer;
|
|
1050
|
+
}
|
|
1051
|
+
function resolveSubOptions(options, key) {
|
|
1052
|
+
return (0, import_utils3.isBoolean)(options[key]) ? {} : options[key] || {};
|
|
1053
|
+
}
|
|
1054
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1055
|
+
0 && (module.exports = {
|
|
1056
|
+
GLOB_ALL_SRC,
|
|
1057
|
+
GLOB_ASTRO,
|
|
1058
|
+
GLOB_CSS,
|
|
1059
|
+
GLOB_EXCLUDE,
|
|
1060
|
+
GLOB_GRAPHQL,
|
|
1061
|
+
GLOB_HTML,
|
|
1062
|
+
GLOB_JS,
|
|
1063
|
+
GLOB_JSON,
|
|
1064
|
+
GLOB_JSON5,
|
|
1065
|
+
GLOB_JSONC,
|
|
1066
|
+
GLOB_JSX,
|
|
1067
|
+
GLOB_LESS,
|
|
1068
|
+
GLOB_MARKDOWN,
|
|
1069
|
+
GLOB_MARKDOWN_CODE,
|
|
1070
|
+
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
1071
|
+
GLOB_POSTCSS,
|
|
1072
|
+
GLOB_SCSS,
|
|
1073
|
+
GLOB_SRC,
|
|
1074
|
+
GLOB_SRC_EXT,
|
|
1075
|
+
GLOB_STYLE,
|
|
1076
|
+
GLOB_SVELTE,
|
|
1077
|
+
GLOB_TESTS,
|
|
1078
|
+
GLOB_TOML,
|
|
1079
|
+
GLOB_TS,
|
|
1080
|
+
GLOB_TSX,
|
|
1081
|
+
GLOB_VUE,
|
|
1082
|
+
GLOB_XML,
|
|
1083
|
+
GLOB_YAML,
|
|
1084
|
+
StylisticConfigDefaults,
|
|
1085
|
+
custom,
|
|
1086
|
+
getVueVersion,
|
|
1087
|
+
gitignore,
|
|
1088
|
+
ignores,
|
|
1089
|
+
imports,
|
|
1090
|
+
javascript,
|
|
1091
|
+
lntvow,
|
|
1092
|
+
prettier,
|
|
1093
|
+
regexp,
|
|
1094
|
+
renameRules,
|
|
1095
|
+
stylistic,
|
|
1096
|
+
test,
|
|
1097
|
+
typescript,
|
|
1098
|
+
vue
|
|
1099
|
+
});
|