@shayanthenerd/eslint-config 0.4.5 → 0.4.6

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.
Files changed (65) hide show
  1. package/dist/configs/base.js +43 -0
  2. package/dist/configs/commons.js +26 -0
  3. package/dist/configs/css.js +28 -0
  4. package/dist/configs/cypress.js +22 -0
  5. package/dist/configs/html.js +22 -0
  6. package/dist/configs/importX.js +45 -0
  7. package/dist/configs/nuxtMultiRootTemplate.js +14 -0
  8. package/dist/configs/oxlintOverrides.js +50 -0
  9. package/dist/configs/perfectionist.js +23 -0
  10. package/dist/configs/playwright.js +22 -0
  11. package/dist/configs/storybook.js +23 -0
  12. package/dist/configs/stylistic.js +22 -0
  13. package/dist/configs/tailwind.js +42 -0
  14. package/dist/configs/typescript.js +30 -0
  15. package/dist/configs/vitest.js +22 -0
  16. package/dist/configs/vue.js +34 -0
  17. package/dist/configs/vueComponentNames.js +19 -0
  18. package/dist/index.d.ts +16 -0
  19. package/dist/index.js +54 -0
  20. package/dist/oxlint.config.jsonc +192 -0
  21. package/dist/prettier.config.d.ts +6 -0
  22. package/dist/prettier.config.js +38 -0
  23. package/dist/rules/css.js +65 -0
  24. package/dist/rules/cypress.js +15 -0
  25. package/dist/rules/html.js +53 -0
  26. package/dist/rules/importX.js +50 -0
  27. package/dist/rules/javascript.js +163 -0
  28. package/dist/rules/perfectionist.js +73 -0
  29. package/dist/rules/playwright.js +27 -0
  30. package/dist/rules/storybook.js +15 -0
  31. package/dist/rules/stylistic.js +160 -0
  32. package/dist/rules/tailwind.js +36 -0
  33. package/dist/rules/typescript.js +62 -0
  34. package/dist/rules/vitest.js +46 -0
  35. package/dist/rules/vue.js +171 -0
  36. package/dist/rules/vueAccessibility.js +23 -0
  37. package/dist/types/configOptions/base.d.ts +47 -0
  38. package/dist/types/configOptions/css.d.ts +27 -0
  39. package/dist/types/configOptions/html.d.ts +27 -0
  40. package/dist/types/configOptions/importX.d.ts +29 -0
  41. package/dist/types/configOptions/nuxt.d.ts +42 -0
  42. package/dist/types/configOptions/perfectionist.d.ts +16 -0
  43. package/dist/types/configOptions/stylistic.d.ts +145 -0
  44. package/dist/types/configOptions/tailwind.d.ts +46 -0
  45. package/dist/types/configOptions/test.d.ts +55 -0
  46. package/dist/types/configOptions/typescript.d.ts +36 -0
  47. package/dist/types/configOptions/vue.d.ts +211 -0
  48. package/dist/types/configOptions/vueAccessibility.d.ts +34 -0
  49. package/dist/types/eslint-schema.d.ts +13732 -0
  50. package/dist/types/eslintRules.d.ts +12 -0
  51. package/dist/types/helpers.d.ts +5 -0
  52. package/dist/types/index.d.ts +360 -0
  53. package/dist/utils/globs.js +31 -0
  54. package/dist/utils/ignores/defaultIgnorePatterns.js +57 -0
  55. package/dist/utils/ignores/getIgnorePatterns.js +16 -0
  56. package/dist/utils/ignores/resolveGitignorePatterns.js +26 -0
  57. package/dist/utils/isEmptyString.js +7 -0
  58. package/dist/utils/isEnabled.js +7 -0
  59. package/dist/utils/isPackageDetected.js +20 -0
  60. package/dist/utils/options/defaultOptions.js +168 -0
  61. package/dist/utils/options/enableDetectedConfigs.js +40 -0
  62. package/dist/utils/options/mergeWithDefaults.js +21 -0
  63. package/dist/utils/vue/getRestrictedVueElements.js +27 -0
  64. package/dist/utils/vue/getRestrictedVueInputs.js +23 -0
  65. package/package.json +2 -1
@@ -0,0 +1,168 @@
1
+ //#region src/utils/options/defaultOptions.ts
2
+ const defaultOptions = {
3
+ autoDetectDeps: true,
4
+ gitignore: ".gitignore",
5
+ env: "node",
6
+ packageDir: ".",
7
+ tsConfig: false,
8
+ global: {
9
+ basePath: ".",
10
+ ignores: [],
11
+ linterOptions: {
12
+ noInlineConfig: false,
13
+ reportUnusedInlineConfigs: "warn",
14
+ reportUnusedDisableDirectives: "warn"
15
+ },
16
+ globals: {
17
+ node: true,
18
+ commonjs: false,
19
+ browser: true,
20
+ worker: true,
21
+ serviceworker: false,
22
+ webextension: false,
23
+ custom: {}
24
+ },
25
+ settings: {},
26
+ rules: {}
27
+ },
28
+ configs: {
29
+ oxlint: "./.oxlintrc.json",
30
+ base: {
31
+ maxDepth: 3,
32
+ maxNestedCallbacks: 3,
33
+ preferNamedExports: true,
34
+ functionStyle: "declaration",
35
+ overrides: {}
36
+ },
37
+ stylistic: {
38
+ semi: "always",
39
+ trailingComma: "always-multiline",
40
+ memberDelimiterStyle: "comma",
41
+ quotes: "single",
42
+ jsxQuotes: "prefer-double",
43
+ arrowParens: "always",
44
+ useTabs: true,
45
+ indent: 2,
46
+ maxConsecutiveEmptyLines: 1,
47
+ maxLineLength: 120,
48
+ maxAttributesPerLine: 3,
49
+ selfCloseVoidHTMLElements: "always",
50
+ overrides: {}
51
+ },
52
+ html: {
53
+ useBaseline: false,
54
+ idNamingConvention: "snake_case",
55
+ overrides: {}
56
+ },
57
+ css: {
58
+ useBaseline: false,
59
+ allowedRelativeFontUnits: ["rem", "em"],
60
+ overrides: {}
61
+ },
62
+ tailwind: {
63
+ multilineSort: true,
64
+ ignoredUnregisteredClasses: [],
65
+ config: "",
66
+ entryPoint: "",
67
+ overrides: {}
68
+ },
69
+ typescript: {
70
+ allowedDefaultProjects: [],
71
+ methodSignatureStyle: "method",
72
+ typeDefinitionStyle: "interface",
73
+ overrides: {}
74
+ },
75
+ importX: {
76
+ removeUnusedImports: true,
77
+ requireFileExtension: true,
78
+ overrides: {}
79
+ },
80
+ perfectionist: {
81
+ sortType: "line-length",
82
+ overrides: {}
83
+ },
84
+ vue: {
85
+ accessibility: {
86
+ imageComponents: ["NuxtImg"],
87
+ anchorComponents: [
88
+ "RouterLink",
89
+ "NuxtLink",
90
+ "ULink"
91
+ ],
92
+ accessibleChildComponents: [
93
+ "img",
94
+ "picture",
95
+ "NuxtImg",
96
+ "NuxtPicture"
97
+ ]
98
+ },
99
+ blocksOrder: [
100
+ "script:not([setup])",
101
+ "script[setup]",
102
+ "template",
103
+ "i18n[locale=en]",
104
+ "i18n:not([locale=en])",
105
+ "style:not([scoped])",
106
+ "style[scoped]",
107
+ "docs"
108
+ ],
109
+ macrosOrder: [
110
+ "definePage",
111
+ "defineOptions",
112
+ "defineModel",
113
+ "defineProps",
114
+ "defineEmits",
115
+ "defineSlots",
116
+ "defineCustom",
117
+ "defineExpose"
118
+ ],
119
+ attributesOrder: [
120
+ "DEFINITION",
121
+ "CONDITIONALS",
122
+ "RENDER_MODIFIERS",
123
+ "LIST_RENDERING",
124
+ "UNIQUE",
125
+ "GLOBAL",
126
+ "TWO_WAY_BINDING",
127
+ "SLOT",
128
+ "CONTENT",
129
+ "OTHER_DIRECTIVES",
130
+ "EVENTS",
131
+ "ATTR_SHORTHAND_BOOL",
132
+ "ATTR_DYNAMIC",
133
+ "ATTR_STATIC"
134
+ ],
135
+ attributeHyphenation: "never",
136
+ preferVBindSameNameShorthand: "always",
137
+ preferVBindTrueShorthand: "always",
138
+ allowedStyleAttributes: ["scoped", "module"],
139
+ blockLang: {
140
+ script: "js",
141
+ style: "implicit"
142
+ },
143
+ destructureProps: "always",
144
+ componentNameCaseInTemplate: "PascalCase",
145
+ vForDelimiterStyle: "in",
146
+ vOnHandlerStyle: ["method", "inline-function"],
147
+ restrictedElements: [],
148
+ restrictedStaticAttributes: [],
149
+ ignoredUndefinedComponents: [],
150
+ overrides: {}
151
+ },
152
+ nuxt: {
153
+ image: false,
154
+ ui: { prefix: "U" }
155
+ },
156
+ test: {
157
+ storybook: { overrides: {} },
158
+ vitest: { overrides: {} },
159
+ playwright: { overrides: {} },
160
+ cypress: { overrides: {} },
161
+ testFunction: "test",
162
+ maxNestedDescribe: 1
163
+ }
164
+ }
165
+ };
166
+
167
+ //#endregion
168
+ export { defaultOptions };
@@ -0,0 +1,40 @@
1
+ import { defaultOptions } from "./defaultOptions.js";
2
+ import { isPackageDetected, logDetectedPackages } from "../isPackageDetected.js";
3
+
4
+ //#region src/utils/options/enableDetectedConfigs.ts
5
+ function enableDetectedConfigs(options) {
6
+ options.configs ??= {};
7
+ options.configs.test ??= {};
8
+ options.configs.html ??= false;
9
+ options.configs.css ??= false;
10
+ options.configs.tailwind ??= false;
11
+ options.configs.importX ??= true;
12
+ options.configs.stylistic ??= true;
13
+ options.configs.perfectionist ??= true;
14
+ options.configs.vue ??= isPackageDetected("vue", options);
15
+ options.configs.nuxt ??= isPackageDetected("nuxt", options);
16
+ options.configs.typescript ??= isPackageDetected("typescript", options);
17
+ options.configs.test.vitest ??= isPackageDetected("vitest", options);
18
+ options.configs.test.cypress ??= isPackageDetected("cypress", options);
19
+ options.configs.test.storybook ??= isPackageDetected("storybook", options);
20
+ options.configs.test.playwright ??= isPackageDetected("@playwright/test", options);
21
+ options.configs.oxlint ??= isPackageDetected("oxlint", options) ? defaultOptions.configs.oxlint : false;
22
+ options.tsConfig ??= options.configs.typescript ? {
23
+ rootDir: ".",
24
+ filename: "tsconfig.json"
25
+ } : false;
26
+ if (options.configs.typescript && options.configs.vue) {
27
+ options.configs.vue = options.configs.vue === true ? {} : options.configs.vue;
28
+ options.configs.vue.blockLang = { script: "ts" };
29
+ }
30
+ if (options.configs.nuxt) {
31
+ if (options.configs.nuxt === true) options.configs.nuxt = {};
32
+ options.configs.nuxt.ui ??= isPackageDetected("@nuxt/ui", options);
33
+ options.configs.nuxt.image ??= isPackageDetected("@nuxt/image", options);
34
+ }
35
+ if (options.autoDetectDeps === "verbose") logDetectedPackages();
36
+ return options;
37
+ }
38
+
39
+ //#endregion
40
+ export { enableDetectedConfigs };
@@ -0,0 +1,21 @@
1
+ import { defaultOptions } from "./defaultOptions.js";
2
+ import { isEmptyString } from "../isEmptyString.js";
3
+ import { enableDetectedConfigs } from "./enableDetectedConfigs.js";
4
+ import { createDefu } from "defu";
5
+
6
+ //#region src/utils/options/mergeWithDefaults.ts
7
+ const mergeOptions = createDefu((object, key, value) => {
8
+ const isValueTrue = value === true;
9
+ const isDefaultValueFalse = object[key] === false;
10
+ const isValueEmptyString = isEmptyString(value);
11
+ const fallBackToDefault = isValueEmptyString || isValueTrue && !isDefaultValueFalse;
12
+ return fallBackToDefault;
13
+ });
14
+ function mergeWithDefaults(options) {
15
+ const optionsWithDetectedConfigs = enableDetectedConfigs(options);
16
+ const mergedOptions = mergeOptions(optionsWithDetectedConfigs, defaultOptions);
17
+ return mergedOptions;
18
+ }
19
+
20
+ //#endregion
21
+ export { mergeWithDefaults };
@@ -0,0 +1,27 @@
1
+ //#region src/utils/vue/getRestrictedVueElements.ts
2
+ const alternativeComponents = {
3
+ kbd: "Kbd",
4
+ form: "Form",
5
+ input: "Input",
6
+ table: "Table",
7
+ dialog: "Modal",
8
+ hr: "Separator",
9
+ button: "Button",
10
+ select: "Select",
11
+ progress: "Progress",
12
+ textarea: "Textarea",
13
+ details: "Accordion",
14
+ datalist: "InputMenu"
15
+ };
16
+ const alternativeComponentPairs = Object.entries(alternativeComponents);
17
+ function getRestrictedVueElements(prefix) {
18
+ const restrictedElements = [];
19
+ for (const [element, component] of alternativeComponentPairs) restrictedElements.push({
20
+ element,
21
+ message: `Use <${prefix}${component}>.`
22
+ });
23
+ return restrictedElements;
24
+ }
25
+
26
+ //#endregion
27
+ export { getRestrictedVueElements };
@@ -0,0 +1,23 @@
1
+ //#region src/utils/vue/getRestrictedVueInputs.ts
2
+ const alternativeComponents = {
3
+ range: "Slider",
4
+ date: "Calendar",
5
+ radio: "RadioGroup",
6
+ checkbox: "Checkbox",
7
+ color: "ColorPicker",
8
+ number: "InputNumber"
9
+ };
10
+ const alternativeComponentPairs = Object.entries(alternativeComponents);
11
+ function getRestrictedVueInputs(prefix) {
12
+ const restrictedInputs = [];
13
+ for (const [input, component] of alternativeComponentPairs) restrictedInputs.push({
14
+ element: "input",
15
+ key: "type",
16
+ value: input,
17
+ message: `Use <${prefix}${component}>.`
18
+ });
19
+ return restrictedInputs;
20
+ }
21
+
22
+ //#endregion
23
+ export { getRestrictedVueInputs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shayanthenerd/eslint-config",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "license": "MIT",
5
5
  "description": "A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style",
6
6
  "keywords": [
@@ -55,6 +55,7 @@
55
55
  "packageManager": "bun@1.2.19",
56
56
  "scripts": {
57
57
  "prepare": "bun set:gitmessage && bunx simple-git-hooks && bun generate:types",
58
+ "prepublishOnly": "bun build:package",
58
59
  "set:gitmessage": "git config --local commit.template \".gitmessage\"",
59
60
  "inspect": "bunx @eslint/config-inspector",
60
61
  "build:package": "tsdown --no-report",