@shayanthenerd/eslint-config 0.31.0 → 0.33.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.
Files changed (39) hide show
  1. package/README.md +76 -42
  2. package/dist/configs/astro.mjs +5 -1
  3. package/dist/configs/javascript.mjs +1 -1
  4. package/dist/configs/packageJson.mjs +1 -1
  5. package/dist/configs/react.mjs +2 -2
  6. package/dist/configs/tailwind.mjs +7 -1
  7. package/dist/configs/tanstack.mjs +26 -0
  8. package/dist/configs/typescript.mjs +4 -6
  9. package/dist/helpers/ignores/defaultIgnorePatterns.mjs +1 -6
  10. package/dist/helpers/options/defaultOptions.mjs +19 -3
  11. package/dist/helpers/options/enableDetectedConfigs.mjs +22 -1
  12. package/dist/index.d.mts +4 -3
  13. package/dist/index.mjs +3 -35
  14. package/dist/rules/astro.mjs +61 -54
  15. package/dist/rules/baseline.mjs +1 -1
  16. package/dist/rules/css.mjs +35 -7
  17. package/dist/rules/html.mjs +3 -2
  18. package/dist/rules/importX.mjs +2 -2
  19. package/dist/rules/javascript.mjs +6 -5
  20. package/dist/rules/next.mjs +2 -0
  21. package/dist/rules/node.mjs +1 -1
  22. package/dist/rules/packageJson.mjs +166 -153
  23. package/dist/rules/perfectionist.mjs +41 -11
  24. package/dist/rules/playwright.mjs +10 -0
  25. package/dist/rules/react.mjs +57 -54
  26. package/dist/rules/stylistic.mjs +1 -1
  27. package/dist/rules/tanstack.mjs +39 -0
  28. package/dist/rules/typescript.mjs +2 -2
  29. package/dist/rules/unicorn.mjs +15 -6
  30. package/dist/rules/vue.mjs +38 -41
  31. package/dist/rules/zod.mjs +2 -0
  32. package/dist/types/eslint-schema.d.mts +851 -651
  33. package/dist/types/index.d.mts +57 -7
  34. package/dist/types/options/baseline.d.mts +24 -3
  35. package/dist/types/options/react.d.mts +9 -9
  36. package/dist/types/options/tanstack.d.mts +32 -0
  37. package/dist/types/options/typescript.d.mts +3 -3
  38. package/dist/types/options/vue.d.mts +1 -1
  39. package/package.json +38 -34
@@ -1,60 +1,67 @@
1
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
1
2
  import { isEnabled } from "../utils/isEnabled.mjs";
2
3
  //#region src/rules/astro.ts
3
- const astroRules = {
4
- "astro/missing-client-only-directive-value": "error",
5
- "astro/no-conflict-set-directives": "error",
6
- "astro/no-deprecated-astro-canonicalurl": "error",
7
- "astro/no-deprecated-astro-fetchcontent": "error",
8
- "astro/no-deprecated-astro-resolve": "error",
9
- "astro/no-deprecated-getentrybyslug": "error",
10
- "astro/no-exports-from-components": "error",
11
- "astro/no-prerender-export-outside-pages": "error",
12
- "astro/no-unused-define-vars-in-style": "warn",
13
- "astro/no-set-html-directive": "warn",
14
- "astro/no-unsafe-inline-scripts": "warn",
15
- "astro/no-set-text-directive": "warn",
16
- "astro/no-unused-css-selector": "warn",
17
- "astro/prefer-class-list-directive": "warn",
18
- "astro/prefer-split-class-list": "warn",
19
- "astro/jsx-a11y/alt-text": "error",
20
- "astro/jsx-a11y/anchor-ambiguous-text": "warn",
21
- "astro/jsx-a11y/anchor-has-content": "warn",
22
- "astro/jsx-a11y/anchor-is-valid": "error",
23
- "astro/jsx-a11y/aria-activedescendant-has-tabindex": "warn",
24
- "astro/jsx-a11y/aria-props": "error",
25
- "astro/jsx-a11y/aria-proptypes": "error",
26
- "astro/jsx-a11y/aria-role": "warn",
27
- "astro/jsx-a11y/aria-unsupported-elements": "error",
28
- "astro/jsx-a11y/autocomplete-valid": "error",
29
- "astro/jsx-a11y/click-events-have-key-events": "warn",
30
- "astro/jsx-a11y/control-has-associated-label": "warn",
31
- "astro/jsx-a11y/heading-has-content": "warn",
32
- "astro/jsx-a11y/html-has-lang": "error",
33
- "astro/jsx-a11y/iframe-has-title": "warn",
34
- "astro/jsx-a11y/img-redundant-alt": "warn",
35
- "astro/jsx-a11y/interactive-supports-focus": "warn",
36
- "astro/jsx-a11y/label-has-associated-control": "warn",
37
- "astro/jsx-a11y/lang": "error",
38
- "astro/jsx-a11y/media-has-caption": "warn",
39
- "astro/jsx-a11y/mouse-events-have-key-events": "warn",
40
- "astro/jsx-a11y/no-access-key": "warn",
41
- "astro/jsx-a11y/no-aria-hidden-on-focusable": "error",
42
- "astro/jsx-a11y/no-autofocus": "warn",
43
- "astro/jsx-a11y/no-distracting-elements": "warn",
44
- "astro/jsx-a11y/no-interactive-element-to-noninteractive-role": "warn",
45
- "astro/jsx-a11y/no-noninteractive-element-interactions": "warn",
46
- "astro/jsx-a11y/no-noninteractive-element-to-interactive-role": "warn",
47
- "astro/jsx-a11y/no-noninteractive-tabindex": "warn",
48
- "astro/jsx-a11y/no-redundant-roles": "warn",
49
- "astro/jsx-a11y/no-static-element-interactions": "warn",
50
- "astro/jsx-a11y/prefer-tag-over-role": "warn",
51
- "astro/jsx-a11y/role-has-required-aria-props": "warn",
52
- "astro/jsx-a11y/role-supports-aria-props": "warn",
53
- "astro/jsx-a11y/scope": "error",
54
- "astro/jsx-a11y/tabindex-no-positive": "warn"
55
- };
56
4
  function getAstroRules(options) {
57
- const { importX, stylistic } = options.configs;
5
+ const { astro, importX, stylistic } = options.configs;
6
+ const { semi } = isEnabled(stylistic) ? stylistic : defaultOptions.configs.stylistic;
7
+ const { accessibility } = isEnabled(astro) ? astro : defaultOptions.configs.astro;
8
+ const astroRules = {
9
+ "astro/missing-client-only-directive-value": "error",
10
+ "astro/no-conflict-set-directives": "error",
11
+ "astro/no-deprecated-astro-canonicalurl": "error",
12
+ "astro/no-deprecated-astro-fetchcontent": "error",
13
+ "astro/no-deprecated-astro-resolve": "error",
14
+ "astro/no-deprecated-getentrybyslug": "error",
15
+ "astro/no-exports-from-components": "error",
16
+ "astro/no-prerender-export-outside-pages": "error",
17
+ "astro/no-unused-define-vars-in-style": "warn",
18
+ "astro/no-set-html-directive": "warn",
19
+ "astro/no-unsafe-inline-scripts": "warn",
20
+ "astro/no-set-text-directive": "warn",
21
+ "astro/no-unused-css-selector": "warn",
22
+ "astro/prefer-class-list-directive": "warn",
23
+ "astro/prefer-split-class-list": "warn",
24
+ "astro/semi": ["warn", semi]
25
+ };
26
+ const astroJsxA11yRules = {
27
+ "astro/jsx-a11y/alt-text": "error",
28
+ "astro/jsx-a11y/anchor-ambiguous-text": "warn",
29
+ "astro/jsx-a11y/anchor-has-content": "warn",
30
+ "astro/jsx-a11y/anchor-is-valid": "error",
31
+ "astro/jsx-a11y/aria-activedescendant-has-tabindex": "warn",
32
+ "astro/jsx-a11y/aria-props": "error",
33
+ "astro/jsx-a11y/aria-proptypes": "error",
34
+ "astro/jsx-a11y/aria-role": "warn",
35
+ "astro/jsx-a11y/aria-unsupported-elements": "error",
36
+ "astro/jsx-a11y/autocomplete-valid": "error",
37
+ "astro/jsx-a11y/click-events-have-key-events": "warn",
38
+ "astro/jsx-a11y/control-has-associated-label": "warn",
39
+ "astro/jsx-a11y/heading-has-content": "warn",
40
+ "astro/jsx-a11y/html-has-lang": "error",
41
+ "astro/jsx-a11y/iframe-has-title": "warn",
42
+ "astro/jsx-a11y/img-redundant-alt": "warn",
43
+ "astro/jsx-a11y/interactive-supports-focus": "warn",
44
+ "astro/jsx-a11y/label-has-associated-control": "warn",
45
+ "astro/jsx-a11y/lang": "error",
46
+ "astro/jsx-a11y/media-has-caption": "warn",
47
+ "astro/jsx-a11y/mouse-events-have-key-events": "warn",
48
+ "astro/jsx-a11y/no-access-key": "warn",
49
+ "astro/jsx-a11y/no-aria-hidden-on-focusable": "error",
50
+ "astro/jsx-a11y/no-autofocus": "warn",
51
+ "astro/jsx-a11y/no-distracting-elements": "warn",
52
+ "astro/jsx-a11y/no-interactive-element-to-noninteractive-role": "warn",
53
+ "astro/jsx-a11y/no-noninteractive-element-interactions": "warn",
54
+ "astro/jsx-a11y/no-noninteractive-element-to-interactive-role": "warn",
55
+ "astro/jsx-a11y/no-noninteractive-tabindex": "warn",
56
+ "astro/jsx-a11y/no-redundant-roles": "warn",
57
+ "astro/jsx-a11y/no-static-element-interactions": "warn",
58
+ "astro/jsx-a11y/prefer-tag-over-role": "warn",
59
+ "astro/jsx-a11y/role-has-required-aria-props": "warn",
60
+ "astro/jsx-a11y/role-supports-aria-props": "warn",
61
+ "astro/jsx-a11y/scope": "error",
62
+ "astro/jsx-a11y/tabindex-no-positive": "warn"
63
+ };
64
+ if (isEnabled(accessibility)) Object.assign(astroRules, astroJsxA11yRules);
58
65
  if (isEnabled(importX)) astroRules["import-x/exports-last"] = "off";
59
66
  if (isEnabled(stylistic)) astroRules["@stylistic/jsx-one-expression-per-line"] = "off";
60
67
  return astroRules;
@@ -14,7 +14,7 @@ function getBaselineRules(options) {
14
14
  baseline,
15
15
  includeWebApis: { preset: "auto" },
16
16
  includeJsBuiltins: { preset: "auto" },
17
- ignoreFeatures: userIgnoredFeatures,
17
+ ignoreFeatures: ["async-clipboard", ...userIgnoredFeatures],
18
18
  ignoreNodeTypes: userIgnoredNodeTypes
19
19
  }]
20
20
  };
@@ -1,5 +1,6 @@
1
1
  import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
+ import { isTruthy } from "../utils/isTruthy.mjs";
3
4
  //#region src/rules/css.ts
4
5
  const allowedPhysicalUnits = [
5
6
  "cqh",
@@ -46,7 +47,8 @@ const allowedPhysicalProperties = [
46
47
  "contain-intrinsic-height"
47
48
  ];
48
49
  function getCssRules(options) {
49
- const { unicorn, tailwind, baseline } = options.configs;
50
+ const { css, vue, unicorn, tailwind, baseline } = options.configs;
51
+ const { allowedUnknownPseudoSelectors: userAllowedUnknownPseudoSelectors } = isEnabled(css) ? css : defaultOptions.configs.css;
50
52
  const { allowedAtRules: userAllowedAtRules, allowedFunctions: userAllowedFunctions, allowedMediaConditions: userAllowedMediaConditions, allowedProperties: userAllowedProperties, allowedPropertyValues: userAllowedPropertyValues, allowedSelectors: userAllowedSelectors, allowedUnits: userAllowedUnits } = isEnabled(baseline) ? baseline.css : defaultOptions.configs.baseline.css;
51
53
  const cssRules = {
52
54
  "css/font-family-fallbacks": "warn",
@@ -82,15 +84,41 @@ function getCssRules(options) {
82
84
  allowFunctions: userAllowedFunctions,
83
85
  allowMediaConditions: userAllowedMediaConditions,
84
86
  allowProperties: userAllowedProperties,
85
- allowPropertyValues: userAllowedPropertyValues,
86
- allowSelectors: userAllowedSelectors,
87
+ allowPropertyValues: {
88
+ "background-clip": ["text"],
89
+ ...userAllowedPropertyValues
90
+ },
91
+ allowSelectors: ["selection", ...userAllowedSelectors],
87
92
  allowUnits: userAllowedUnits
88
93
  }] : "off"
89
94
  };
90
- if (isEnabled(unicorn)) {
91
- cssRules["unicorn/no-shorthand-property-overrides"] = "warn";
92
- cssRules["unicorn/prefer-explicit-viewport-units"] = "warn";
93
- }
95
+ const unicornRules = {
96
+ "unicorn/no-deprecated-css-features": "error",
97
+ "unicorn/no-duplicate-css-selectors": "warn",
98
+ "unicorn/no-duplicate-font-family-names": "error",
99
+ "unicorn/no-invalid-media-features": "error",
100
+ "unicorn/no-nesting-with-mixed-specificity": "warn",
101
+ "unicorn/no-redundant-nested-style-rules": "warn",
102
+ "unicorn/no-shorthand-property-overrides": "warn",
103
+ "unicorn/no-unknown-css-annotations": "error",
104
+ "unicorn/no-unknown-pseudo-selectors": ["error", { allow: [
105
+ "::-ms-reveal",
106
+ ":-webkit-autofill",
107
+ "::-webkit-inner-spin-button",
108
+ "::-webkit-search-cancel-button",
109
+ "::-webkit-search-results-button",
110
+ ...isEnabled(vue) ? [
111
+ ":deep",
112
+ ":global",
113
+ ":slotted"
114
+ ] : [],
115
+ ...userAllowedUnknownPseudoSelectors
116
+ ].filter(isTruthy) }],
117
+ "unicorn/no-unscoped-css-nesting-selector": isEnabled(tailwind) ? ["error", { scopingRootAtRules: ["utility", "custom-variant"] }] : "error",
118
+ "unicorn/prefer-explicit-viewport-units": "warn",
119
+ "unicorn/prefer-media-feature-range-syntax": "warn"
120
+ };
121
+ if (isEnabled(unicorn)) Object.assign(cssRules, unicornRules);
94
122
  return cssRules;
95
123
  }
96
124
  //#endregion
@@ -55,7 +55,7 @@ function getHtmlRules(options) {
55
55
  "@html-eslint/require-input-label": "error",
56
56
  "@html-eslint/require-meta-viewport": "error"
57
57
  };
58
- if (isEnabled(stylistic)) Object.assign(htmlRules, {
58
+ const stylisticRules = {
59
59
  "@html-eslint/attrs-newline": ["warn", {
60
60
  maxLen: maxLineLength,
61
61
  ifAttrsMoreThan: maxAttributesPerLine
@@ -78,7 +78,8 @@ function getHtmlRules(options) {
78
78
  "double",
79
79
  { enforceTemplatedAttrValue: true }
80
80
  ]
81
- });
81
+ };
82
+ if (isEnabled(stylistic)) Object.assign(htmlRules, stylisticRules);
82
83
  if (isEnabled(tailwind)) htmlRules["better-tailwindcss/no-duplicate-classes"] = "off";
83
84
  if (isEnabled(unicorn)) htmlRules["unicorn/no-invalid-file-input-accept"] = "error";
84
85
  return htmlRules;
@@ -2,7 +2,7 @@ import { isEnabled } from "../utils/isEnabled.mjs";
2
2
  import path from "node:path";
3
3
  //#region src/rules/importX.ts
4
4
  function getImportXRules(options) {
5
- const { packageDir, configs: { typescript } } = options;
5
+ const { packageDir, configs: { unicorn, typescript } } = options;
6
6
  const isTypescriptEnabled = isEnabled(typescript);
7
7
  return {
8
8
  "import-x/export": isTypescriptEnabled ? "off" : "error",
@@ -15,7 +15,7 @@ function getImportXRules(options) {
15
15
  "import-x/no-mutable-exports": "error",
16
16
  "import-x/no-named-as-default": "error",
17
17
  "import-x/no-amd": "error",
18
- "import-x/no-commonjs": "error",
18
+ "import-x/no-commonjs": isEnabled(unicorn) ? "off" : "error",
19
19
  "import-x/no-import-module-exports": "error",
20
20
  "import-x/named": isTypescriptEnabled ? "off" : "error",
21
21
  "import-x/default": isTypescriptEnabled ? "off" : "error",
@@ -1,7 +1,8 @@
1
1
  import { isEnabled } from "../utils/isEnabled.mjs";
2
2
  //#region src/rules/javascript.ts
3
3
  function getJavaScriptRules(options) {
4
- const { unicorn, typescript, javascript: { maxDepth, maxNestedCallbacks } } = options.configs;
4
+ const { importX, unicorn, typescript, javascript: { maxDepth, maxNestedCallbacks } } = options.configs;
5
+ const isImportXEnabled = isEnabled(importX);
5
6
  const isUnicornEnabled = isEnabled(unicorn);
6
7
  const isTypescriptEnabled = isEnabled(typescript);
7
8
  return {
@@ -26,7 +27,7 @@ function getJavaScriptRules(options) {
26
27
  "no-dupe-class-members": isTypescriptEnabled ? "off" : "error",
27
28
  "no-dupe-else-if": "error",
28
29
  "no-dupe-keys": isTypescriptEnabled ? "off" : "error",
29
- "no-duplicate-case": "error",
30
+ "no-duplicate-case": isImportXEnabled ? "off" : "error",
30
31
  "no-duplicate-imports": ["error", {
31
32
  includeExports: true,
32
33
  allowSeparateTypeImports: true
@@ -190,7 +191,7 @@ function getJavaScriptRules(options) {
190
191
  "no-useless-call": "error",
191
192
  "no-useless-catch": "error",
192
193
  "no-useless-computed-key": "error",
193
- "no-useless-concat": "error",
194
+ "no-useless-concat": isUnicornEnabled ? "error" : "off",
194
195
  "no-useless-constructor": "error",
195
196
  "no-useless-escape": "error",
196
197
  "no-useless-rename": "error",
@@ -200,7 +201,7 @@ function getJavaScriptRules(options) {
200
201
  "no-with": "error",
201
202
  "object-shorthand": "warn",
202
203
  "operator-assignment": "warn",
203
- "prefer-arrow-callback": ["warn", { allowUnboundThis: true }],
204
+ "prefer-arrow-callback": "warn",
204
205
  "prefer-const": "error",
205
206
  "prefer-destructuring": isTypescriptEnabled ? "off" : ["warn", {
206
207
  object: true,
@@ -214,7 +215,7 @@ function getJavaScriptRules(options) {
214
215
  "prefer-promise-reject-errors": isTypescriptEnabled ? "off" : ["warn", { allowEmptyReject: true }],
215
216
  "prefer-regex-literals": ["warn", { disallowRedundantWrapping: true }],
216
217
  "prefer-rest-params": "warn",
217
- "prefer-spread": "warn",
218
+ "prefer-spread": isUnicornEnabled ? "warn" : "off",
218
219
  "prefer-template": "warn",
219
220
  "preserve-caught-error": "warn",
220
221
  "radix": "warn",
@@ -4,6 +4,7 @@ const nextRules = {
4
4
  "next/google-font-preconnect": "warn",
5
5
  "next/inline-script-id": "error",
6
6
  "next/next-script-for-ga": "warn",
7
+ "next/no-assign-module-variable": "error",
7
8
  "next/no-async-client-component": "error",
8
9
  "next/no-before-interactive-script-outside-document": "error",
9
10
  "next/no-css-tags": "warn",
@@ -13,6 +14,7 @@ const nextRules = {
13
14
  "next/no-head-import-in-document": "error",
14
15
  "next/no-html-link-for-pages": "warn",
15
16
  "next/no-img-element": "warn",
17
+ "next/no-location-assign-relative-destination": "error",
16
18
  "next/no-page-custom-font": "warn",
17
19
  "next/no-script-component-in-head": "error",
18
20
  "next/no-styled-jsx-in-document": "error",
@@ -11,7 +11,7 @@ function getNodeRules(options) {
11
11
  "n/no-path-concat": "error",
12
12
  "n/no-process-env": ["error", { allowedVariables: ["NODE_ENV"] }],
13
13
  "n/no-process-exit": "error",
14
- "n/no-sync": "warn",
14
+ "n/no-sync": isEnabled(typescript) ? "warn" : "off",
15
15
  "n/no-unpublished-import": "error",
16
16
  "n/no-unsupported-features/es-builtins": "error",
17
17
  "n/no-unsupported-features/es-syntax": "error",
@@ -1,157 +1,170 @@
1
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
2
+ import { isEnabled } from "../utils/isEnabled.mjs";
1
3
  //#region src/rules/packageJson.ts
2
- const packageJsonRules = {
3
- "package-json/bin-name-casing": "warn",
4
- "package-json/exports-subpaths-style": ["warn", { prefer: "implicit" }],
5
- "package-json/no-empty-fields": "error",
6
- "package-json/no-local-dependencies": "error",
7
- "package-json/no-redundant-files": "error",
8
- "package-json/no-redundant-publishConfig": "error",
9
- "package-json/order-properties": "warn",
10
- "package-json/repository-shorthand": "warn",
11
- "package-json/require-attribution": ["warn", { ignorePrivate: true }],
12
- "package-json/require-bugs": "warn",
13
- "package-json/require-description": ["warn", { ignorePrivate: true }],
14
- "package-json/require-devEngines": "warn",
15
- "package-json/require-engines": ["warn", { ignorePrivate: true }],
16
- "package-json/require-exports": ["error", { ignorePrivate: true }],
17
- "package-json/require-files": ["error", { ignorePrivate: true }],
18
- "package-json/require-homepage": "warn",
19
- "package-json/require-keywords": "warn",
20
- "package-json/require-license": ["error", { ignorePrivate: true }],
21
- "package-json/require-name": "error",
22
- "package-json/require-repository": "warn",
23
- "package-json/require-type": "warn",
24
- "package-json/require-types": ["error", { ignorePrivate: true }],
25
- "package-json/require-version": "error",
26
- "package-json/restrict-dependency-ranges": ["warn", [{
27
- forDependencyTypes: ["dependencies", "devDependencies"],
28
- rangeType: "pin"
29
- }, {
30
- forDependencyTypes: ["peerDependencies", "optionalDependencies"],
31
- rangeType: ["caret", "tilde"]
32
- }]],
33
- "package-json/restrict-private-properties": ["error", { blockedProperties: [
34
- "files",
35
- "publishConfig",
36
- "keywords",
37
- "funding"
38
- ] }],
39
- "package-json/restrict-top-level-properties": ["warn", { ban: [
40
- {
41
- property: "bun",
42
- message: "use bunfig.toml."
43
- },
44
- {
45
- property: "pnpm",
46
- message: "use pnpm-workspace.yaml."
47
- },
48
- {
49
- property: "commitlint",
50
- message: "use a dedicated config file."
51
- },
52
- {
53
- property: "stylelint",
54
- message: "use a dedicated config file."
55
- },
56
- {
57
- property: "prettier",
58
- message: "use a dedicated config file."
59
- },
60
- {
61
- property: "renovate",
62
- message: "use a dedicated config file."
63
- }
64
- ] }],
65
- "package-json/scripts-name-casing": "warn",
66
- "package-json/sort-collections": ["warn", [
67
- {
68
- key: "author",
69
- order: [
70
- "name",
71
- "email",
72
- "url"
73
- ]
74
- },
75
- {
76
- key: "bugs",
77
- order: ["email", "url"]
78
- },
79
- "config",
80
- "dependencies",
81
- "devEngines",
82
- "devDependencies",
83
- "directories",
84
- {
85
- key: "dist",
86
- order: ["shasum", "tarball"]
87
- },
88
- "engines",
89
- "exports",
90
- "husky",
91
- "husky.hooks",
92
- "lint-staged",
93
- "nano-staged",
94
- "optionalDependencies",
95
- "overrides",
96
- "peerDependencies",
97
- "peerDependenciesMeta",
98
- {
99
- key: "repository",
100
- order: [
101
- "type",
102
- "url",
103
- "directory"
104
- ]
105
- },
106
- "release",
107
- "simple-git-hooks"
108
- ]],
109
- "package-json/specify-peers-locally": "warn",
110
- "package-json/unique-dependencies": "error",
111
- "package-json/valid-author": "error",
112
- "package-json/valid-bin": "error",
113
- "package-json/valid-browser": "error",
114
- "package-json/valid-bugs": "error",
115
- "package-json/valid-bundleDependencies": "error",
116
- "package-json/valid-config": "error",
117
- "package-json/valid-contributors": "error",
118
- "package-json/valid-cpu": "error",
119
- "package-json/valid-dependencies": "error",
120
- "package-json/valid-description": "error",
121
- "package-json/valid-devDependencies": "error",
122
- "package-json/valid-devEngines": "error",
123
- "package-json/valid-directories": "error",
124
- "package-json/valid-engines": "error",
125
- "package-json/valid-exports": "error",
126
- "package-json/valid-files": "error",
127
- "package-json/valid-funding": "error",
128
- "package-json/valid-gypfile": "error",
129
- "package-json/valid-homepage": "error",
130
- "package-json/valid-keywords": "error",
131
- "package-json/valid-libc": "error",
132
- "package-json/valid-license": "error",
133
- "package-json/valid-main": "error",
134
- "package-json/valid-man": "error",
135
- "package-json/valid-module": "error",
136
- "package-json/valid-name": "error",
137
- "package-json/valid-optionalDependencies": "error",
138
- "package-json/valid-os": "error",
139
- "package-json/valid-packageManager": "error",
140
- "package-json/valid-peerDependencies": "error",
141
- "package-json/valid-peerDependenciesMeta": "error",
142
- "package-json/valid-peerDependenciesMeta-relationship": "error",
143
- "package-json/valid-private": "error",
144
- "package-json/valid-publishConfig": "error",
145
- "package-json/valid-repository": "error",
146
- "package-json/valid-repository-directory": "error",
147
- "package-json/valid-scripts": "error",
148
- "package-json/valid-sideEffects": "error",
149
- "package-json/valid-type": "error",
150
- "package-json/valid-version": "error",
151
- "package-json/valid-workspaces": "error"
152
- };
153
- function getPackageJsonRules() {
154
- return packageJsonRules;
4
+ /**
5
+ Using a wildcard to target all objects within an array isn't supported yet.
6
+ @see https://github.com/michaelfaith/eslint-plugin-package-json/issues/1967
7
+ */
8
+ const collectionSortPatterns = [
9
+ {
10
+ key: "author",
11
+ order: [
12
+ "name",
13
+ "email",
14
+ "url"
15
+ ]
16
+ },
17
+ {
18
+ key: "bugs",
19
+ order: ["email", "url"]
20
+ },
21
+ "config",
22
+ "dependencies",
23
+ "devEngines",
24
+ "devDependencies",
25
+ "directories",
26
+ {
27
+ key: "dist",
28
+ order: ["shasum", "tarball"]
29
+ },
30
+ "engines",
31
+ "exports",
32
+ "husky",
33
+ "husky.hooks",
34
+ "lint-staged",
35
+ "nano-staged",
36
+ "optionalDependencies",
37
+ "overrides",
38
+ "peerDependencies",
39
+ "peerDependenciesMeta",
40
+ {
41
+ key: "repository",
42
+ order: [
43
+ "type",
44
+ "url",
45
+ "directory"
46
+ ]
47
+ },
48
+ "release",
49
+ "simple-git-hooks"
50
+ ];
51
+ function getPackageJsonRules(options) {
52
+ const { packageJson } = options.configs;
53
+ const { allowedDistTags: userUseAllowedDistTags, allowedDistTagsFor: userUseAllowedDistTagsFor } = isEnabled(packageJson) ? packageJson : defaultOptions.configs.packageJson;
54
+ return {
55
+ "package-json/bin-name-casing": "warn",
56
+ "package-json/exports-subpaths-style": ["warn", { prefer: "implicit" }],
57
+ "package-json/no-empty-fields": "error",
58
+ "package-json/no-local-dependencies": "error",
59
+ "package-json/no-redundant-files": "error",
60
+ "package-json/no-redundant-publishConfig": "error",
61
+ "package-json/order-properties": "warn",
62
+ "package-json/repository-shorthand": "warn",
63
+ "package-json/require-attribution": "warn",
64
+ "package-json/require-package-json-export": "error",
65
+ "package-json/require-bugs": "warn",
66
+ "package-json/require-description": ["warn", { ignorePrivate: true }],
67
+ "package-json/require-devEngines": "warn",
68
+ "package-json/require-engines": ["warn", { ignorePrivate: true }],
69
+ "package-json/require-exports": ["error", { ignorePrivate: true }],
70
+ "package-json/require-files": ["error", { ignorePrivate: true }],
71
+ "package-json/require-homepage": "warn",
72
+ "package-json/require-keywords": "warn",
73
+ "package-json/require-license": ["error", { ignorePrivate: true }],
74
+ "package-json/require-name": "error",
75
+ "package-json/require-repository": "warn",
76
+ "package-json/require-type": "warn",
77
+ "package-json/require-types": ["error", { ignorePrivate: true }],
78
+ "package-json/require-version": "error",
79
+ "package-json/restrict-dependency-ranges": ["warn", [{
80
+ forDependencyTypes: ["dependencies", "devDependencies"],
81
+ rangeType: "pin"
82
+ }, {
83
+ forDependencyTypes: ["peerDependencies", "optionalDependencies"],
84
+ rangeType: ["caret", "tilde"]
85
+ }]],
86
+ "package-json/restrict-dist-tags": ["warn", {
87
+ allowed: userUseAllowedDistTags,
88
+ allowedFor: userUseAllowedDistTagsFor
89
+ }],
90
+ "package-json/restrict-private-properties": ["error", { blockedProperties: [
91
+ "files",
92
+ "publishConfig",
93
+ "keywords",
94
+ "funding"
95
+ ] }],
96
+ "package-json/restrict-top-level-properties": ["warn", { ban: [
97
+ {
98
+ property: "bun",
99
+ message: "use bunfig.toml."
100
+ },
101
+ {
102
+ property: "pnpm",
103
+ message: "use pnpm-workspace.yaml."
104
+ },
105
+ {
106
+ property: "commitlint",
107
+ message: "use a dedicated config file."
108
+ },
109
+ {
110
+ property: "stylelint",
111
+ message: "use a dedicated config file."
112
+ },
113
+ {
114
+ property: "prettier",
115
+ message: "use a dedicated config file."
116
+ },
117
+ {
118
+ property: "renovate",
119
+ message: "use a dedicated config file."
120
+ }
121
+ ] }],
122
+ "package-json/scripts-name-casing": "warn",
123
+ "package-json/sort-collections": ["warn", collectionSortPatterns],
124
+ "package-json/specify-peers-locally": "warn",
125
+ "package-json/unique-dependencies": "error",
126
+ "package-json/valid-author": "error",
127
+ "package-json/valid-bin": "error",
128
+ "package-json/valid-browser": "error",
129
+ "package-json/valid-bugs": "error",
130
+ "package-json/valid-bundleDependencies": "error",
131
+ "package-json/valid-config": "error",
132
+ "package-json/valid-contributors": "error",
133
+ "package-json/valid-cpu": "error",
134
+ "package-json/valid-dependencies": "error",
135
+ "package-json/valid-description": "error",
136
+ "package-json/valid-devDependencies": "error",
137
+ "package-json/valid-devEngines": "error",
138
+ "package-json/valid-directories": "error",
139
+ "package-json/valid-engines": "error",
140
+ "package-json/valid-exports": "error",
141
+ "package-json/valid-files": "error",
142
+ "package-json/valid-funding": "error",
143
+ "package-json/valid-gypfile": "error",
144
+ "package-json/valid-homepage": "error",
145
+ "package-json/valid-keywords": "error",
146
+ "package-json/valid-libc": "error",
147
+ "package-json/valid-license": "error",
148
+ "package-json/valid-main": "error",
149
+ "package-json/valid-man": "error",
150
+ "package-json/valid-module": "error",
151
+ "package-json/valid-name": "error",
152
+ "package-json/valid-optionalDependencies": "error",
153
+ "package-json/valid-os": "error",
154
+ "package-json/valid-packageManager": "error",
155
+ "package-json/valid-peerDependencies": "error",
156
+ "package-json/valid-peerDependenciesMeta": "error",
157
+ "package-json/valid-peerDependenciesMeta-relationship": "error",
158
+ "package-json/valid-private": "error",
159
+ "package-json/valid-publishConfig": "error",
160
+ "package-json/valid-repository": "error",
161
+ "package-json/valid-repository-directory": "error",
162
+ "package-json/valid-scripts": "error",
163
+ "package-json/valid-sideEffects": "error",
164
+ "package-json/valid-type": "error",
165
+ "package-json/valid-version": "error",
166
+ "package-json/valid-workspaces": "error"
167
+ };
155
168
  }
156
169
  //#endregion
157
170
  export { getPackageJsonRules };