@dauphaihau/eslint-config 0.2.3 → 0.3.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 +8 -1
- package/dist/chunk-3KIOV3DX.js +31 -0
- package/dist/dist-TWVRNVXF.js +235031 -0
- package/dist/index.js +100 -0
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -599,6 +599,60 @@ async function tailwindConfig(options = {}) {
|
|
|
599
599
|
];
|
|
600
600
|
}
|
|
601
601
|
|
|
602
|
+
// src/configs/vue.ts
|
|
603
|
+
async function vueConfig(options = {}) {
|
|
604
|
+
const vueFiles = strategyManager.getVueFiles(options);
|
|
605
|
+
if (vueFiles.length === 0) {
|
|
606
|
+
return [];
|
|
607
|
+
}
|
|
608
|
+
const { default: pluginVue } = await import("eslint-plugin-vue");
|
|
609
|
+
const recommendedConfigs = pluginVue.configs["flat/recommended"];
|
|
610
|
+
const [pluginSetup, parserSetup, ...ruleConfigs] = recommendedConfigs;
|
|
611
|
+
const mergedRules = ruleConfigs.reduce(
|
|
612
|
+
(acc, c) => ({ ...acc, ...c.rules }),
|
|
613
|
+
{}
|
|
614
|
+
);
|
|
615
|
+
const tsParser = options.typescript ? (await import("typescript-eslint")).parser : void 0;
|
|
616
|
+
const parserConfig = tsParser ? {
|
|
617
|
+
...parserSetup,
|
|
618
|
+
languageOptions: {
|
|
619
|
+
...parserSetup.languageOptions,
|
|
620
|
+
parserOptions: {
|
|
621
|
+
...parserSetup.languageOptions?.parserOptions,
|
|
622
|
+
parser: tsParser
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
} : parserSetup;
|
|
626
|
+
return [
|
|
627
|
+
pluginSetup,
|
|
628
|
+
// registers vue plugin globally
|
|
629
|
+
parserConfig,
|
|
630
|
+
// vue-eslint-parser + processor for *.vue files
|
|
631
|
+
{
|
|
632
|
+
name: "dauphaihau/vue",
|
|
633
|
+
files: vueFiles,
|
|
634
|
+
rules: {
|
|
635
|
+
...mergedRules,
|
|
636
|
+
"vue/comment-directive": "off",
|
|
637
|
+
// meta-rule; disable directives handled by ESLint core
|
|
638
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
639
|
+
"vue/component-definition-name-casing": ["error", "PascalCase"],
|
|
640
|
+
"vue/multi-word-component-names": "warn",
|
|
641
|
+
"vue/no-v-html": "warn",
|
|
642
|
+
"vue/html-self-closing": ["error", {
|
|
643
|
+
html: { void: "always", normal: "always", component: "always" },
|
|
644
|
+
svg: "always",
|
|
645
|
+
math: "always"
|
|
646
|
+
}],
|
|
647
|
+
"vue/attribute-hyphenation": ["error", "always"],
|
|
648
|
+
"vue/no-unused-vars": "error",
|
|
649
|
+
"vue/no-use-v-if-with-v-for": "error",
|
|
650
|
+
"vue/require-v-for-key": "error"
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
];
|
|
654
|
+
}
|
|
655
|
+
|
|
602
656
|
// src/configs/naming.ts
|
|
603
657
|
import ts2 from "typescript-eslint";
|
|
604
658
|
var identifierQualityRules = {
|
|
@@ -681,6 +735,12 @@ var baseNamingSelectors = [
|
|
|
681
735
|
format: null
|
|
682
736
|
// allow anything -> API response, snake_case keys allowed
|
|
683
737
|
},
|
|
738
|
+
{
|
|
739
|
+
// External type declarations may expose quoted keys such as 'flat/recommended'.
|
|
740
|
+
selector: "typeProperty",
|
|
741
|
+
modifiers: ["requiresQuotes"],
|
|
742
|
+
format: null
|
|
743
|
+
},
|
|
684
744
|
{
|
|
685
745
|
// internal domain types
|
|
686
746
|
selector: "typeProperty",
|
|
@@ -804,6 +864,7 @@ var ESLintConfigBuilder = class {
|
|
|
804
864
|
this.fileNamesAdded = false;
|
|
805
865
|
this.typescriptAdded = false;
|
|
806
866
|
this.reactAdded = false;
|
|
867
|
+
this.vueAdded = false;
|
|
807
868
|
this.tailwindAdded = false;
|
|
808
869
|
}
|
|
809
870
|
/**
|
|
@@ -884,6 +945,21 @@ var ESLintConfigBuilder = class {
|
|
|
884
945
|
this.reactAdded = true;
|
|
885
946
|
return this;
|
|
886
947
|
}
|
|
948
|
+
/**
|
|
949
|
+
* Add Vue-specific rules and plugins.
|
|
950
|
+
* Requires vue option to be set to true.
|
|
951
|
+
*/
|
|
952
|
+
withVue(options) {
|
|
953
|
+
const mergedOptions = { ...this.options, ...options };
|
|
954
|
+
if (!mergedOptions.vue) {
|
|
955
|
+
console.warn(
|
|
956
|
+
"ESLintConfigBuilder: Vue config added but vue option is not set. Consider calling setOptions({ vue: true }) first."
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
this.pendingConfigs.push(vueConfig(mergedOptions));
|
|
960
|
+
this.vueAdded = true;
|
|
961
|
+
return this;
|
|
962
|
+
}
|
|
887
963
|
/**
|
|
888
964
|
* Add Tailwind CSS-specific rules and plugins.
|
|
889
965
|
* Requires tailwind option to be set to true.
|
|
@@ -928,6 +1004,9 @@ var ESLintConfigBuilder = class {
|
|
|
928
1004
|
if (mergedOptions.react) {
|
|
929
1005
|
this.withReact(mergedOptions);
|
|
930
1006
|
}
|
|
1007
|
+
if (mergedOptions.vue) {
|
|
1008
|
+
this.withVue(mergedOptions);
|
|
1009
|
+
}
|
|
931
1010
|
if (mergedOptions.tailwind) {
|
|
932
1011
|
this.withTailwind(mergedOptions);
|
|
933
1012
|
}
|
|
@@ -954,6 +1033,7 @@ var ESLintConfigBuilder = class {
|
|
|
954
1033
|
this.fileNamesAdded = false;
|
|
955
1034
|
this.typescriptAdded = false;
|
|
956
1035
|
this.reactAdded = false;
|
|
1036
|
+
this.vueAdded = false;
|
|
957
1037
|
this.tailwindAdded = false;
|
|
958
1038
|
return this;
|
|
959
1039
|
}
|
|
@@ -984,6 +1064,9 @@ var ESLintConfigBuilder = class {
|
|
|
984
1064
|
hasReact() {
|
|
985
1065
|
return this.reactAdded;
|
|
986
1066
|
}
|
|
1067
|
+
hasVue() {
|
|
1068
|
+
return this.vueAdded;
|
|
1069
|
+
}
|
|
987
1070
|
hasTailwind() {
|
|
988
1071
|
return this.tailwindAdded;
|
|
989
1072
|
}
|
|
@@ -1008,6 +1091,22 @@ var hasReact = () => {
|
|
|
1008
1091
|
}
|
|
1009
1092
|
return false;
|
|
1010
1093
|
};
|
|
1094
|
+
var hasVue = () => {
|
|
1095
|
+
try {
|
|
1096
|
+
const packageJsonPath = "package.json";
|
|
1097
|
+
if (fs3.existsSync(packageJsonPath)) {
|
|
1098
|
+
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
1099
|
+
const deps = {
|
|
1100
|
+
...packageJson.dependencies,
|
|
1101
|
+
...packageJson.devDependencies,
|
|
1102
|
+
...packageJson.peerDependencies
|
|
1103
|
+
};
|
|
1104
|
+
return "vue" in deps;
|
|
1105
|
+
}
|
|
1106
|
+
} catch {
|
|
1107
|
+
}
|
|
1108
|
+
return false;
|
|
1109
|
+
};
|
|
1011
1110
|
var hasTailwind = () => {
|
|
1012
1111
|
try {
|
|
1013
1112
|
const packageJsonPath = "package.json";
|
|
@@ -1028,6 +1127,7 @@ function eslintConfig(options = {}) {
|
|
|
1028
1127
|
const finalOptions = {
|
|
1029
1128
|
typescript: options.typescript ?? hasTsConfig,
|
|
1030
1129
|
react: options.react ?? hasReact(),
|
|
1130
|
+
vue: options.vue ?? hasVue(),
|
|
1031
1131
|
tailwind: options.tailwind ?? hasTailwind(),
|
|
1032
1132
|
...options
|
|
1033
1133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dauphaihau/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
},
|
|
35
35
|
"eslint-plugin-tailwindcss": {
|
|
36
36
|
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"eslint-plugin-vue": {
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
"vue-eslint-parser": {
|
|
42
|
+
"optional": true
|
|
37
43
|
}
|
|
38
44
|
},
|
|
39
45
|
"devDependencies": {
|
|
@@ -43,13 +49,15 @@
|
|
|
43
49
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
50
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
45
51
|
"eslint-plugin-tailwindcss": "^3.18.2",
|
|
52
|
+
"eslint-plugin-vue": "^10.0.0",
|
|
53
|
+
"vue-eslint-parser": "^10.0.0",
|
|
46
54
|
"jiti": "^2.0.0",
|
|
47
55
|
"tsup": "^8.0.0",
|
|
48
56
|
"typescript": "^5.4.0",
|
|
49
57
|
"vitest": "^3.2.4"
|
|
50
58
|
},
|
|
51
59
|
"scripts": {
|
|
52
|
-
"build": "pnpm exec tsup src/index.ts --dts --format esm --external @eslint/js --external @stylistic/eslint-plugin --external typescript-eslint --external eslint-plugin-check-file --external eslint-plugin-react --external eslint-plugin-react-hooks --external eslint-plugin-react-refresh --external eslint-plugin-tailwindcss",
|
|
60
|
+
"build": "pnpm exec tsup src/index.ts --dts --format esm --external @eslint/js --external @stylistic/eslint-plugin --external typescript-eslint --external eslint-plugin-check-file --external eslint-plugin-react --external eslint-plugin-react-hooks --external eslint-plugin-react-refresh --external eslint-plugin-tailwindcss --external eslint-plugin-vue --external vue-eslint-parser",
|
|
53
61
|
"lint": "eslint .",
|
|
54
62
|
"lint:fix": "eslint . --fix",
|
|
55
63
|
"test": "vitest run",
|