my-code-style 1.0.0 → 1.4.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.
@@ -4,24 +4,45 @@
4
4
  * Prettier plugin rules — mirrors base.cjs prettier/prettier config
5
5
  */
6
6
  export const prettierRules = {
7
- "prettier/prettier": ["error", { singleQuote: false, tabWidth: 4 }],
7
+ "prettier/prettier": [
8
+ "error",
9
+ {
10
+ singleQuote: false,
11
+ tabWidth: 4,
12
+ semi: false,
13
+ trailingComma: "all",
14
+ endOfLine: "lf",
15
+ },
16
+ ],
8
17
  }
9
18
 
10
19
  /**
11
20
  * Common rules shared across all flat config levels — mirrors base.cjs rules
12
21
  */
13
22
  export const commonRules = {
23
+ // 缩进由 Prettier 统一负责,关闭 ESLint 缩进避免打架
24
+ indent: "off",
25
+ semi: ["error", "never"],
26
+ quotes: ["error", "double", { avoidEscape: false, allowTemplateLiterals: true }],
27
+ curly: ["error", "all"],
28
+ "comma-dangle": ["error", "always-multiline"],
29
+ "object-curly-spacing": ["error", "always"],
30
+ "array-bracket-spacing": ["error", "never"],
31
+
14
32
  // Import rules (using import-x for flat config compatibility)
15
33
  "import-x/no-unresolved": "off",
16
- "import-x/extensions": [
17
- "error",
18
- "ignorePackages",
19
- { js: "never", jsx: "never", ts: "never", tsx: "never" },
20
- ],
34
+ "import-x/extensions": "off",
21
35
  "import-x/prefer-default-export": "off",
22
36
  "import-x/no-extraneous-dependencies": "off",
37
+
23
38
  // TypeScript
24
39
  "@typescript-eslint/no-redeclare": "error",
40
+ "@typescript-eslint/no-explicit-any": "off",
41
+ "@typescript-eslint/no-unused-vars": "off",
42
+ "@typescript-eslint/no-unused-expressions": "off",
43
+ "@typescript-eslint/ban-ts-comment": "off",
44
+ "@typescript-eslint/no-empty-object-type": "off",
45
+
25
46
  // Commonly disabled
26
47
  "no-console": "off",
27
48
  "no-plusplus": "off",
@@ -30,12 +51,14 @@ export const commonRules = {
30
51
  "no-use-before-define": "off",
31
52
  "no-undef": "off",
32
53
  "no-unused-vars": "off",
54
+ "no-unused-expressions": "off",
33
55
  "no-param-reassign": "off",
34
- "@typescript-eslint/no-unused-vars": "off",
35
56
  "no-redeclare": "off",
36
57
  "prefer-promise-reject-errors": "off",
37
- // Quotes
38
- quotes: ["error", "double", { avoidEscape: false, allowTemplateLiterals: true }],
58
+
59
+ // Standard JS uses @stylistic style/quotes disable to avoid conflict
60
+ "style/quotes": "off",
61
+ "style/semi": "off",
39
62
  }
40
63
 
41
64
  /**
@@ -11,7 +11,15 @@ import { prettierRules, commonRules } from "./_shared.mjs"
11
11
  export default [
12
12
  // Ignore patterns
13
13
  {
14
- ignores: ["**/node_modules/**", "**/dist/**", "**/coverage/**"],
14
+ ignores: [
15
+ "**/node_modules/**",
16
+ "**/dist/**",
17
+ "**/coverage/**",
18
+ "**/public/**",
19
+ "**/assets/iconfont/**",
20
+ "**/*.min.js",
21
+ "**/*.min.css",
22
+ ],
15
23
  },
16
24
 
17
25
  // TypeScript recommended rules
@@ -21,7 +29,7 @@ export default [
21
29
  // eslint-plugin-import-x configuration
22
30
  // Replaces: plugin:import/recommended + eslint-config-standard (via FlatCompat)
23
31
  {
24
- files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
32
+ files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,nvue}"],
25
33
  plugins: {
26
34
  "import-x": importX,
27
35
  },
@@ -36,16 +44,9 @@ export default [
36
44
  },
37
45
  },
38
46
 
39
- // Prettier integration
40
- // Replaces: extends: ["plugin:prettier/recommended"]
41
- eslintPluginPrettierRecommended,
42
-
43
- // eslint-config-prettier MUST be last — disables conflicting ESLint rules
44
- eslintConfigPrettier,
45
-
46
- // Global language options + shared rules
47
+ // Global language options for JS/TS/JSX/TSX
47
48
  {
48
- files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
49
+ files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
49
50
  languageOptions: {
50
51
  ecmaVersion: "latest",
51
52
  sourceType: "module",
@@ -58,11 +59,27 @@ export default [
58
59
  parserOptions: {
59
60
  ecmaVersion: "latest",
60
61
  sourceType: "module",
62
+ ecmaFeatures: {
63
+ jsx: true,
64
+ },
61
65
  },
62
66
  },
67
+ },
68
+
69
+ // Shared rules for all JS, TS, JSX, TSX and Vue files
70
+ {
71
+ files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx,vue,nvue}"],
63
72
  rules: {
64
- ...prettierRules,
65
73
  ...commonRules,
74
+ ...prettierRules,
75
+ },
76
+ },
77
+
78
+ // CommonJS files and config files legitimately need require()
79
+ {
80
+ files: ["**/*.cjs", "**/.*rc.js", "**/*.config.js"],
81
+ rules: {
82
+ "@typescript-eslint/no-require-imports": "off",
66
83
  },
67
84
  },
68
85
 
@@ -75,4 +92,10 @@ export default [
75
92
  },
76
93
  },
77
94
  },
95
+
96
+ // Prettier integration (replaces: extends: ["plugin:prettier/recommended"])
97
+ eslintPluginPrettierRecommended,
98
+
99
+ // eslint-config-prettier MUST be last — disables conflicting ESLint rules
100
+ eslintConfigPrettier,
78
101
  ]
@@ -1,6 +1,8 @@
1
1
  // Vue 3 ESLint Flat Config — extends base, adds Vue-specific rules
2
2
 
3
3
  import pluginVue from "eslint-plugin-vue"
4
+ import tseslint from "typescript-eslint"
5
+ import parserVue from "vue-eslint-parser"
4
6
  import baseConfig from "./base.mjs"
5
7
 
6
8
  export default [
@@ -8,39 +10,47 @@ export default [
8
10
  ...baseConfig,
9
11
 
10
12
  // Vue 3 essential rules
11
- // Replaces: extends: ["plugin:vue/vue3-essential"]
12
- // Must scope to .vue files only
13
13
  ...pluginVue.configs["flat/essential"].map((config) => ({
14
14
  ...config,
15
- files: ["**/*.vue"],
15
+ files: ["**/*.{vue,nvue}"],
16
16
  })),
17
17
 
18
18
  // Vue plugin setup and custom overrides
19
19
  {
20
- files: ["**/*.vue"],
20
+ files: ["**/*.{vue,nvue}"],
21
21
  languageOptions: {
22
+ parser: parserVue,
22
23
  parserOptions: {
23
- parser: "@typescript-eslint/parser",
24
+ parser: tseslint.parser,
24
25
  sourceType: "module",
26
+ ecmaVersion: "latest",
27
+ extraFileExtensions: [".vue", ".nvue"],
25
28
  },
26
29
  },
27
30
  rules: {
28
31
  "vue/multi-word-component-names": "off",
29
32
  "@typescript-eslint/no-explicit-any": "off",
30
33
  "vue/no-mutating-props": ["error", { shallowOnly: true }],
34
+ "vue/html-indent": "off",
35
+ "vue/script-indent": "off",
36
+ "vue/html-self-closing": "off",
37
+ "vue/max-attributes-per-line": "off",
38
+ "vue/singleline-html-element-content-newline": "off",
31
39
  },
32
40
  },
33
41
 
34
42
  // .nvue specific overrides
35
43
  {
36
- files: ["*.nvue"],
44
+ files: ["**/*.nvue"],
37
45
  languageOptions: {
38
46
  parserOptions: {
39
- sourceType: "script",
47
+ sourceType: "module",
40
48
  },
41
49
  },
42
50
  rules: {
43
51
  "vue/comment-directive": "off",
52
+ // Prettier cannot infer a parser from the custom .nvue extension.
53
+ "prettier/prettier": ["error", { parser: "vue", semi: true }],
44
54
  },
45
55
  },
46
56
  ]
@@ -3,21 +3,41 @@ const base = require("./base.cjs")
3
3
 
4
4
  module.exports = {
5
5
  ...base,
6
- extends: [...base.extends, "plugin:vue/vue3-essential"],
6
+ parser: "vue-eslint-parser",
7
+ extends: [...base.extends, "plugin:vue/essential"],
8
+ parserOptions: {
9
+ ...base.parserOptions,
10
+ parser: "@typescript-eslint/parser",
11
+ extraFileExtensions: [".vue", ".nvue"],
12
+ },
7
13
  plugins: [...base.plugins, "vue"],
8
14
  overrides: [
9
15
  {
10
16
  env: { node: true },
11
- files: [".eslintrc.{js,cjs}", "*.nvue"],
17
+ files: [".eslintrc.{js,cjs}"],
12
18
  parserOptions: { sourceType: "script" },
13
19
  rules: { "vue/comment-directive": "off" },
14
20
  },
15
21
  ...(base.overrides || []),
22
+ {
23
+ files: ["**/*.nvue"],
24
+ parserOptions: { sourceType: "module" },
25
+ rules: {
26
+ "vue/comment-directive": "off",
27
+ semi: "off",
28
+ "prettier/prettier": ["error", { parser: "vue", semi: true }],
29
+ },
30
+ },
16
31
  ],
17
32
  rules: {
18
33
  ...base.rules,
19
34
  "vue/multi-word-component-names": "off",
20
35
  "@typescript-eslint/no-explicit-any": "off",
21
36
  "vue/no-mutating-props": ["error", { shallowOnly: true }],
37
+ "vue/html-indent": "off",
38
+ "vue/script-indent": "off",
39
+ "vue/html-self-closing": "off",
40
+ "vue/max-attributes-per-line": "off",
41
+ "vue/singleline-html-element-content-newline": "off",
22
42
  },
23
43
  }
package/src/gitattributes CHANGED
@@ -1,4 +1,10 @@
1
- * text eol=lf
1
+ # Automatically normalize line endings (to LF) for all text-based files.
2
+ * text=auto eol=lf
3
+
4
+ # Windows scripts — must use CRLF
5
+ *.{cmd,[cC][mM][dD]} text eol=crlf
6
+ *.{bat,[bB][aA][tT]} text eol=crlf
7
+ *.{ps1,[pP][sS]1} text eol=crlf
2
8
 
3
9
  # Binary files — do not apply EOL conversion
4
10
  *.aar binary
@@ -16,4 +22,4 @@
16
22
  *.woff binary
17
23
  *.woff2 binary
18
24
  *.apk binary
19
- *.plist binary
25
+ *.plist binary
package/src/gitignore ADDED
@@ -0,0 +1,10 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ *.local
5
+ *.log
6
+ .DS_Store
7
+ .idea/
8
+ .vscode/
9
+ *.tgz
10
+ .eslintcache
@@ -1,4 +1 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx --no-install commitlint --edit
1
+ npx --no-install commitlint --edit "${1}"
@@ -1,4 +1 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
1
  npx --no-install -- lint-staged
@@ -10,12 +10,21 @@ module.exports = {
10
10
  htmlWhitespaceSensitivity: "ignore",
11
11
  overrides: [
12
12
  {
13
- files: "*.json",
14
- options: { trailingComma: "none" },
13
+ files: ["*.json", "*.json5"],
14
+ options: {
15
+ tabWidth: 2,
16
+ trailingComma: "none",
17
+ },
18
+ },
19
+ {
20
+ files: ["*.yml", "*.yaml"],
21
+ options: {
22
+ tabWidth: 2,
23
+ },
15
24
  },
16
25
  {
17
26
  files: "*.nvue",
18
- options: { semi: true },
27
+ options: { parser: "vue", semi: true },
19
28
  },
20
29
  ],
21
30
  }
@@ -9,9 +9,17 @@ module.exports = {
9
9
  "stylelint-config-recess-order",
10
10
  ],
11
11
  plugins: ["stylelint-prettier"],
12
+ ignoreFiles: [
13
+ "**/node_modules/**",
14
+ "**/dist/**",
15
+ "**/coverage/**",
16
+ "**/public/**",
17
+ "**/assets/iconfont/**",
18
+ "**/*.min.css",
19
+ ],
12
20
  overrides: [
13
21
  {
14
- files: ["**/*.{vue,html}"],
22
+ files: ["**/*.{vue,nvue,html}"],
15
23
  customSyntax: "postcss-html",
16
24
  },
17
25
  {
@@ -51,5 +59,18 @@ module.exports = {
51
59
  "scss/comment-no-empty": null,
52
60
  "selector-class-pattern": null,
53
61
  "font-family-no-missing-generic-family-keyword": null,
62
+ // 现代 CSS 语法与选择器宽松放行
63
+ "selector-not-notation": null,
64
+ "import-notation": null,
65
+ "media-feature-range-notation": null,
66
+ "no-descending-specificity": null,
67
+ // 业务样式容错放行
68
+ "block-no-empty": null,
69
+ "scss/at-extend-no-missing-placeholder": null,
70
+ // 兼容混合 Less 及 Vue 内嵌 Less 语法,避免 stylelint-scss 规则解析崩溃或误报
71
+ "scss/operator-no-newline-after": null,
72
+ "scss/operator-no-newline-before": null,
73
+ "scss/operator-no-unspaced": null,
74
+ "scss/no-global-function-names": null,
54
75
  },
55
76
  }
@@ -8,9 +8,17 @@ module.exports = {
8
8
  "stylelint-config-recess-order",
9
9
  ],
10
10
  plugins: ["stylelint-prettier"],
11
+ ignoreFiles: [
12
+ "**/node_modules/**",
13
+ "**/dist/**",
14
+ "**/coverage/**",
15
+ "**/public/**",
16
+ "**/assets/iconfont/**",
17
+ "**/*.min.css",
18
+ ],
11
19
  overrides: [
12
20
  {
13
- files: ["**/*.{vue,html}"],
21
+ files: ["**/*.{vue,nvue,html}"],
14
22
  customSyntax: "postcss-html",
15
23
  },
16
24
  {
@@ -45,5 +53,12 @@ module.exports = {
45
53
  "no-duplicate-selectors": null,
46
54
  "selector-class-pattern": null,
47
55
  "font-family-no-missing-generic-family-keyword": null,
56
+ // 现代 CSS 语法与选择器宽松放行
57
+ "selector-not-notation": null,
58
+ "import-notation": null,
59
+ "media-feature-range-notation": null,
60
+ "no-descending-specificity": null,
61
+ // 业务样式容错放行
62
+ "block-no-empty": null,
48
63
  },
49
- }
64
+ }