eslint-plugin-package-json 1.5.0 → 1.6.1
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 +107 -106
- package/{lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/definitions/jsonSchema.d.mts → dist/createRule-29pC9RoP.d.mts} +49 -4
- package/dist/experimental/index.d.mts +68 -0
- package/{lib/experimental/plugin.mjs → dist/experimental/index.mjs} +10 -5
- package/dist/index.d.mts +99 -0
- package/{lib → dist}/index.mjs +1 -1
- package/dist/plugin-C-Z8sf5g.mjs +1737 -0
- package/package.json +33 -27
- package/lib/createRule.d.mts +0 -59
- package/lib/createRule.mjs +0 -24
- package/lib/experimental/index.d.mts +0 -34
- package/lib/experimental/index.mjs +0 -7
- package/lib/experimental/plugin.d.mts +0 -40
- package/lib/index.d.mts +0 -49
- package/lib/node_modules/.pnpm/@types_estree@1.0.8/node_modules/@types/estree/index.d.mts +0 -438
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/definitions/deserializationPattern.d.mts +0 -7
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/definitions/fromSchemaOptions.d.mts +0 -20
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/index.d.mts +0 -11
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-options.d.mts +0 -16
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/allOf.d.mts +0 -13
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/anyOf.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/array.d.mts +0 -58
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/const.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/deserialize.d.mts +0 -13
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/enum.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/ifThenElse.d.mts +0 -20
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/index.d.mts +0 -34
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/multipleTypes.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/not.d.mts +0 -20
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/nullable.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/object.d.mts +0 -34
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/oneOf.d.mts +0 -14
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/references/external.d.mts +0 -22
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/references/index.d.mts +0 -13
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/references/internal.d.mts +0 -8
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/references/utils.d.mts +0 -12
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/singleType.d.mts +0 -24
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/parse-schema/utils.d.mts +0 -20
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/and.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/extends.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/get.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/join.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/not.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/pop.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/split.d.mts +0 -7
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/tail.d.mts +0 -4
- package/lib/node_modules/.pnpm/json-schema-to-ts@3.1.1/node_modules/json-schema-to-ts/lib/types/type-utils/writable.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/any.d.mts +0 -20
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/array.d.mts +0 -28
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/const.d.mts +0 -25
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/enum.d.mts +0 -25
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/any.d.mts +0 -16
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/array.d.mts +0 -20
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/const.d.mts +0 -28
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/enum.d.mts +0 -23
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/index.d.mts +0 -24
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/object.d.mts +0 -44
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/primitive.d.mts +0 -16
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/tuple.d.mts +0 -43
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/union.d.mts +0 -13
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/exclusion/utils.d.mts +0 -35
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/any.d.mts +0 -23
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/array.d.mts +0 -24
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/const.d.mts +0 -34
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/enum.d.mts +0 -26
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/index.d.mts +0 -24
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/object.d.mts +0 -25
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/primitive.d.mts +0 -23
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/tuple.d.mts +0 -26
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/union.d.mts +0 -17
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/intersection/utils.d.mts +0 -10
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/never.d.mts +0 -9
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/object.d.mts +0 -49
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/primitive.d.mts +0 -26
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/resolve.d.mts +0 -22
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/tuple.d.mts +0 -36
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/type.d.mts +0 -18
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/union.d.mts +0 -23
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/meta-types/utils.d.mts +0 -7
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/and.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/extends.d.mts +0 -7
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/if.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/intersectUnion.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/isNever.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/merge.d.mts +0 -6
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/not.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/or.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/prettify.d.mts +0 -6
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/tail.d.mts +0 -4
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/unionLast.d.mts +0 -6
- package/lib/node_modules/.pnpm/ts-algebra@2.0.0/node_modules/ts-algebra/lib/utils/unionPop.d.mts +0 -6
- package/lib/plugin.d.mts +0 -56
- package/lib/plugin.mjs +0 -93
- package/lib/rules/bin-name-casing.d.mts +0 -6
- package/lib/rules/bin-name-casing.mjs +0 -41
- package/lib/rules/exports-subpaths-style.d.mts +0 -18
- package/lib/rules/exports-subpaths-style.mjs +0 -71
- package/lib/rules/no-empty-fields.d.mts +0 -20
- package/lib/rules/no-empty-fields.mjs +0 -90
- package/lib/rules/no-local-dependencies.d.mts +0 -17
- package/lib/rules/no-local-dependencies.mjs +0 -47
- package/lib/rules/no-redundant-files.d.mts +0 -6
- package/lib/rules/no-redundant-files.mjs +0 -100
- package/lib/rules/no-redundant-publishConfig.d.mts +0 -6
- package/lib/rules/no-redundant-publishConfig.mjs +0 -50
- package/lib/rules/order-properties.d.mts +0 -25
- package/lib/rules/order-properties.mjs +0 -64
- package/lib/rules/repository-shorthand.d.mts +0 -18
- package/lib/rules/repository-shorthand.mjs +0 -111
- package/lib/rules/require-attribution.d.mts +0 -22
- package/lib/rules/require-attribution.mjs +0 -91
- package/lib/rules/require-properties.d.mts +0 -22
- package/lib/rules/require-properties.mjs +0 -74
- package/lib/rules/restrict-dependency-ranges.d.mts +0 -92
- package/lib/rules/restrict-dependency-ranges.mjs +0 -147
- package/lib/rules/restrict-private-properties.d.mts +0 -20
- package/lib/rules/restrict-private-properties.mjs +0 -53
- package/lib/rules/restrict-top-level-properties.d.mts +0 -39
- package/lib/rules/restrict-top-level-properties.mjs +0 -73
- package/lib/rules/scripts-name-casing.d.mts +0 -6
- package/lib/rules/scripts-name-casing.mjs +0 -44
- package/lib/rules/sort-collections.d.mts +0 -35
- package/lib/rules/sort-collections.mjs +0 -111
- package/lib/rules/specify-peers-locally.d.mts +0 -6
- package/lib/rules/specify-peers-locally.mjs +0 -63
- package/lib/rules/unique-dependencies.d.mts +0 -6
- package/lib/rules/unique-dependencies.mjs +0 -87
- package/lib/rules/valid-author.d.mts +0 -6
- package/lib/rules/valid-author.mjs +0 -59
- package/lib/rules/valid-peerDependenciesMeta-relationship.d.mts +0 -6
- package/lib/rules/valid-peerDependenciesMeta-relationship.mjs +0 -50
- package/lib/rules/valid-properties.d.mts +0 -9
- package/lib/rules/valid-properties.mjs +0 -57
- package/lib/rules/valid-repository-directory.d.mts +0 -6
- package/lib/rules/valid-repository-directory.mjs +0 -73
- package/lib/types/estree.d.mts +0 -8
- package/lib/utils/createSimpleRequirePropertyRule.d.mts +0 -48
- package/lib/utils/createSimpleRequirePropertyRule.mjs +0 -62
- package/lib/utils/createSimpleValidPropertyRule.d.mts +0 -17
- package/lib/utils/createSimpleValidPropertyRule.mjs +0 -57
- package/lib/utils/findPropertyWithKeyValue.d.mts +0 -10
- package/lib/utils/findPropertyWithKeyValue.mjs +0 -6
- package/lib/utils/formatErrors.d.mts +0 -9
- package/lib/utils/formatErrors.mjs +0 -12
- package/lib/utils/git/getGitAuthor.d.mts +0 -8
- package/lib/utils/git/getGitAuthor.mjs +0 -29
- package/lib/utils/git/index.d.mts +0 -2
- package/lib/utils/git/index.mjs +0 -2
- package/lib/utils/predicates/index.d.mts +0 -4
- package/lib/utils/predicates/index.mjs +0 -4
- package/lib/utils/predicates/isJSONStringLiteral.d.mts +0 -6
- package/lib/utils/predicates/isJSONStringLiteral.mjs +0 -6
- package/lib/utils/predicates/isNotNullish.d.mts +0 -4
- package/lib/utils/predicates/isNotNullish.mjs +0 -6
- package/lib/utils/predicates/isPackageJson.d.mts +0 -4
- package/lib/utils/predicates/isPackageJson.mjs +0 -4
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
|
|
2
|
-
import { isNotNullish } from "../utils/predicates/isNotNullish.mjs";
|
|
3
|
-
import { createRule } from "../createRule.mjs";
|
|
4
|
-
import { fixRemoveArrayElement, fixRemoveObjectProperty } from "eslint-fix-utils";
|
|
5
|
-
//#region src/rules/unique-dependencies.ts
|
|
6
|
-
const dependencyPropertyNames = new Set([
|
|
7
|
-
"bundledDependencies",
|
|
8
|
-
"bundleDependencies",
|
|
9
|
-
"dependencies",
|
|
10
|
-
"devDependencies",
|
|
11
|
-
"optionalDependencies",
|
|
12
|
-
"overrides",
|
|
13
|
-
"peerDependencies"
|
|
14
|
-
]);
|
|
15
|
-
const rule = createRule({
|
|
16
|
-
create(context) {
|
|
17
|
-
const dependenciesCache = {
|
|
18
|
-
dependencies: [],
|
|
19
|
-
devDependencies: [],
|
|
20
|
-
peerDependencies: []
|
|
21
|
-
};
|
|
22
|
-
const trackForCrossGroupUniqueness = Object.keys(dependenciesCache);
|
|
23
|
-
function check(elements, getNodeToRemove) {
|
|
24
|
-
const seen = /* @__PURE__ */ new Set();
|
|
25
|
-
for (const element of elements.filter(isNotNullish).filter(isJSONStringLiteral).reverse()) if (seen.has(element.value)) report(element);
|
|
26
|
-
else seen.add(element.value);
|
|
27
|
-
function report(node) {
|
|
28
|
-
const removal = getNodeToRemove(node);
|
|
29
|
-
context.report({
|
|
30
|
-
messageId: "overridden",
|
|
31
|
-
node,
|
|
32
|
-
suggest: [{
|
|
33
|
-
fix: removal.type === "JSONProperty" ? fixRemoveObjectProperty(context, removal) : fixRemoveArrayElement(context, removal, elements),
|
|
34
|
-
messageId: "remove"
|
|
35
|
-
}]
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.type=JSONLiteral]"(node) {
|
|
41
|
-
if (!dependencyPropertyNames.has(node.key.value)) return;
|
|
42
|
-
const nodeValueType = node.value.type;
|
|
43
|
-
if (nodeValueType === "JSONArrayExpression") check(node.value.elements, (element) => element);
|
|
44
|
-
if (nodeValueType === "JSONObjectExpression") {
|
|
45
|
-
check(node.value.properties.map((property) => property.key), (property) => property.parent);
|
|
46
|
-
if (trackForCrossGroupUniqueness.includes(node.key.value)) dependenciesCache[node.key.value] = node.value.properties;
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"Program:exit"() {
|
|
50
|
-
const dependencyNames = new Set(dependenciesCache.dependencies.map((node) => node.key).filter(isJSONStringLiteral).map((dependencyNameNode) => dependencyNameNode.value));
|
|
51
|
-
if (!dependencyNames.size) return;
|
|
52
|
-
for (const dependencyType of ["devDependencies", "peerDependencies"]) {
|
|
53
|
-
const otherDependencies = dependenciesCache[dependencyType];
|
|
54
|
-
for (const otherDependencyNode of otherDependencies) {
|
|
55
|
-
const otherDependencyKey = otherDependencyNode.key;
|
|
56
|
-
if (isJSONStringLiteral(otherDependencyKey) && dependencyNames.has(otherDependencyKey.value)) context.report({
|
|
57
|
-
messageId: "crossGroupDuplicate",
|
|
58
|
-
node: otherDependencyNode,
|
|
59
|
-
suggest: [{
|
|
60
|
-
fix: fixRemoveObjectProperty(context, otherDependencyNode),
|
|
61
|
-
messageId: "remove"
|
|
62
|
-
}]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
meta: {
|
|
70
|
-
docs: {
|
|
71
|
-
category: "Best Practices",
|
|
72
|
-
description: "Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`)",
|
|
73
|
-
recommended: true
|
|
74
|
-
},
|
|
75
|
-
hasSuggestions: true,
|
|
76
|
-
messages: {
|
|
77
|
-
crossGroupDuplicate: "Dependency is also declared in \"dependencies\" and is redundant",
|
|
78
|
-
overridden: "Dependency is overridden by a duplicate entry later on",
|
|
79
|
-
remove: "Remove this redundant dependency"
|
|
80
|
-
},
|
|
81
|
-
schema: [],
|
|
82
|
-
type: "suggestion"
|
|
83
|
-
},
|
|
84
|
-
name: "unique-dependencies"
|
|
85
|
-
});
|
|
86
|
-
//#endregion
|
|
87
|
-
export { rule };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
|
|
2
|
-
import { createRule } from "../createRule.mjs";
|
|
3
|
-
import { getGitAuthor } from "../utils/git/getGitAuthor.mjs";
|
|
4
|
-
import { validateAuthor } from "package-json-validator";
|
|
5
|
-
//#region src/rules/valid-author.ts
|
|
6
|
-
const rule = createRule({
|
|
7
|
-
create(context) {
|
|
8
|
-
const createFixer = (propertyName, node) => {
|
|
9
|
-
const author = getGitAuthor();
|
|
10
|
-
if (!author) return;
|
|
11
|
-
let mergedAuthor = author;
|
|
12
|
-
const originalValue = JSON.parse(context.sourceCode.getText(node));
|
|
13
|
-
if (originalValue && typeof originalValue === "object" && !Array.isArray(originalValue)) mergedAuthor = {
|
|
14
|
-
name: author.name,
|
|
15
|
-
...originalValue
|
|
16
|
-
};
|
|
17
|
-
switch (propertyName) {
|
|
18
|
-
case "author": return (fixer) => fixer.replaceText(node, JSON.stringify(mergedAuthor, null, 2).split("\n").join("\n "));
|
|
19
|
-
case "email": return (fixer) => fixer.replaceText(node, JSON.stringify(author.email));
|
|
20
|
-
case "name": return (fixer) => fixer.replaceText(node, JSON.stringify(author.name));
|
|
21
|
-
default: return;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const reportIssues = (result, node, propertyName) => {
|
|
25
|
-
if (result.errorMessages.length === 0) return;
|
|
26
|
-
if (result.issues.length) for (const issue of result.issues) context.report({
|
|
27
|
-
data: { error: issue.message },
|
|
28
|
-
fix: propertyName === void 0 ? void 0 : createFixer(propertyName, node),
|
|
29
|
-
messageId: "validationError",
|
|
30
|
-
node
|
|
31
|
-
});
|
|
32
|
-
const childrenWithIssues = result.childResults.filter((childResult) => childResult.errorMessages.length);
|
|
33
|
-
if (node.type === "JSONObjectExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
34
|
-
const childNode = node.properties[childResult.index];
|
|
35
|
-
const childPropertyName = childNode.key;
|
|
36
|
-
reportIssues(childResult, childNode.value, isJSONStringLiteral(childPropertyName) ? childPropertyName.value : void 0);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=author]"(node) {
|
|
40
|
-
const valueNode = node.value;
|
|
41
|
-
reportIssues(validateAuthor(JSON.parse(context.sourceCode.getText(valueNode))), valueNode, "author");
|
|
42
|
-
} };
|
|
43
|
-
},
|
|
44
|
-
meta: {
|
|
45
|
-
docs: {
|
|
46
|
-
category: "Best Practices",
|
|
47
|
-
description: "Enforce that the `author` property is valid.",
|
|
48
|
-
recommended: true,
|
|
49
|
-
ruleGroup: "valid-properties"
|
|
50
|
-
},
|
|
51
|
-
fixable: "code",
|
|
52
|
-
messages: { validationError: `Invalid author: {{ error }}` },
|
|
53
|
-
schema: [],
|
|
54
|
-
type: "problem"
|
|
55
|
-
},
|
|
56
|
-
name: "valid-author"
|
|
57
|
-
});
|
|
58
|
-
//#endregion
|
|
59
|
-
export { rule };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
|
|
2
|
-
import { createRule } from "../createRule.mjs";
|
|
3
|
-
import { fixRemoveObjectProperty } from "eslint-fix-utils";
|
|
4
|
-
//#region src/rules/valid-peerDependenciesMeta-relationship.ts
|
|
5
|
-
const rule = createRule({
|
|
6
|
-
create(context) {
|
|
7
|
-
const peerDependencies = /* @__PURE__ */ new Set();
|
|
8
|
-
const peerDependenciesMeta = /* @__PURE__ */ new Map();
|
|
9
|
-
return {
|
|
10
|
-
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=peerDependencies]"(node) {
|
|
11
|
-
if (node.value.type === "JSONObjectExpression") {
|
|
12
|
-
for (const property of node.value.properties) if (isJSONStringLiteral(property.key)) peerDependencies.add(property.key.value);
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=peerDependenciesMeta]"(node) {
|
|
16
|
-
if (node.value.type === "JSONObjectExpression") {
|
|
17
|
-
for (const property of node.value.properties) if (isJSONStringLiteral(property.key)) peerDependenciesMeta.set(property.key.value, property);
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"Program:exit"() {
|
|
21
|
-
for (const [dependencyName, propertyNode] of peerDependenciesMeta) if (!peerDependencies.has(dependencyName)) context.report({
|
|
22
|
-
data: { dependencyName },
|
|
23
|
-
messageId: "unnecessaryPeerDependency",
|
|
24
|
-
node: propertyNode,
|
|
25
|
-
suggest: [{
|
|
26
|
-
fix: fixRemoveObjectProperty(context, propertyNode),
|
|
27
|
-
messageId: "removePeerDependencyMeta"
|
|
28
|
-
}]
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
meta: {
|
|
34
|
-
docs: {
|
|
35
|
-
category: "Best Practices",
|
|
36
|
-
description: "Enforces that any dependencies declared in `peerDependenciesMeta` are also defined in the package's `peerDependencies`.",
|
|
37
|
-
recommended: true
|
|
38
|
-
},
|
|
39
|
-
hasSuggestions: true,
|
|
40
|
-
messages: {
|
|
41
|
-
removePeerDependencyMeta: "Remove from `peerDependenciesMeta`.",
|
|
42
|
-
unnecessaryPeerDependency: "Dependency '{{ dependencyName }}' is declared in `peerDependenciesMeta` but not in `peerDependencies`."
|
|
43
|
-
},
|
|
44
|
-
schema: [],
|
|
45
|
-
type: "problem"
|
|
46
|
-
},
|
|
47
|
-
name: "valid-peerDependenciesMeta-relationship"
|
|
48
|
-
});
|
|
49
|
-
//#endregion
|
|
50
|
-
export { rule };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.mjs";
|
|
2
|
-
import { validateBin, validateBrowser, validateBugs, validateBundleDependencies, validateConfig, validateContributors, validateCpu, validateDependencies, validateDescription, validateDevEngines, validateDirectories, validateEngines, validateExports, validateFiles, validateFunding, validateGypfile, validateHomepage, validateKeywords, validateLibc, validateLicense, validateMain, validateMan, validateName, validateOs, validatePackageManager, validatePeerDependenciesMeta, validatePrivate, validatePublishConfig, validateRepository, validateScripts, validateSideEffects, validateType, validateVersion, validateWorkspaces } from "package-json-validator";
|
|
3
|
-
/** All basic valid- flavor rules */
|
|
4
|
-
const rules = Object.fromEntries([
|
|
5
|
-
["bin", validateBin],
|
|
6
|
-
["browser", validateBrowser],
|
|
7
|
-
["bugs", validateBugs],
|
|
8
|
-
["bundleDependencies", {
|
|
9
|
-
aliases: ["bundledDependencies"],
|
|
10
|
-
validator: validateBundleDependencies
|
|
11
|
-
}],
|
|
12
|
-
["config", validateConfig],
|
|
13
|
-
["contributors", validateContributors],
|
|
14
|
-
["cpu", validateCpu],
|
|
15
|
-
["description", validateDescription],
|
|
16
|
-
["dependencies", validateDependencies],
|
|
17
|
-
["devDependencies", validateDependencies],
|
|
18
|
-
["devEngines", validateDevEngines],
|
|
19
|
-
["directories", validateDirectories],
|
|
20
|
-
["engines", validateEngines],
|
|
21
|
-
["exports", validateExports],
|
|
22
|
-
["files", validateFiles],
|
|
23
|
-
["funding", validateFunding],
|
|
24
|
-
["gypfile", validateGypfile],
|
|
25
|
-
["homepage", validateHomepage],
|
|
26
|
-
["keywords", validateKeywords],
|
|
27
|
-
["libc", validateLibc],
|
|
28
|
-
["license", validateLicense],
|
|
29
|
-
["main", validateMain],
|
|
30
|
-
["man", validateMan],
|
|
31
|
-
["module", validateMain],
|
|
32
|
-
["name", validateName],
|
|
33
|
-
["optionalDependencies", validateDependencies],
|
|
34
|
-
["os", validateOs],
|
|
35
|
-
["packageManager", validatePackageManager],
|
|
36
|
-
["peerDependencies", validateDependencies],
|
|
37
|
-
["peerDependenciesMeta", validatePeerDependenciesMeta],
|
|
38
|
-
["private", validatePrivate],
|
|
39
|
-
["publishConfig", validatePublishConfig],
|
|
40
|
-
["repository", validateRepository],
|
|
41
|
-
["scripts", validateScripts],
|
|
42
|
-
["sideEffects", validateSideEffects],
|
|
43
|
-
["type", validateType],
|
|
44
|
-
["version", validateVersion],
|
|
45
|
-
["workspaces", validateWorkspaces]
|
|
46
|
-
].map(([propertyName, validationFunctionOrOptions]) => {
|
|
47
|
-
let validationFunction;
|
|
48
|
-
let aliases = [];
|
|
49
|
-
if (typeof validationFunctionOrOptions === "object") {
|
|
50
|
-
validationFunction = validationFunctionOrOptions.validator;
|
|
51
|
-
aliases = validationFunctionOrOptions.aliases;
|
|
52
|
-
} else validationFunction = validationFunctionOrOptions;
|
|
53
|
-
const { rule, ruleName } = createSimpleValidPropertyRule(propertyName, validationFunction, aliases);
|
|
54
|
-
return [ruleName, rule];
|
|
55
|
-
}));
|
|
56
|
-
//#endregion
|
|
57
|
-
export { rules };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../createRule.mjs";
|
|
2
|
-
import { findPropertyWithKeyValue } from "../utils/findPropertyWithKeyValue.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { sep } from "node:path/posix";
|
|
5
|
-
import { findRootSync } from "@altano/repository-tools";
|
|
6
|
-
//#region src/rules/valid-repository-directory.ts
|
|
7
|
-
/**
|
|
8
|
-
* Checks if the child path appears at the end of the parent path.
|
|
9
|
-
* @example '/a/b/c', 'c' => true
|
|
10
|
-
* @example '/a/b/c', 'b/c' => true
|
|
11
|
-
* @example '/a/b/c', 'b' => false
|
|
12
|
-
* @example '/a/b/c', 'd' => false
|
|
13
|
-
*/
|
|
14
|
-
const pathEndsWith = (parent, child) => {
|
|
15
|
-
if (parent === child) return true;
|
|
16
|
-
const segments = parent.split(path.sep);
|
|
17
|
-
let pathToCheck = "";
|
|
18
|
-
return segments.reverse().some((segment) => {
|
|
19
|
-
pathToCheck = path.join(segment, pathToCheck);
|
|
20
|
-
if (pathToCheck === child) return true;
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
let repoRootCache = null;
|
|
24
|
-
const rule = createRule({
|
|
25
|
-
create(context) {
|
|
26
|
-
return { "Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=repository][value.type=JSONObjectExpression]"(node) {
|
|
27
|
-
const directoryProperty = findPropertyWithKeyValue(node.value.properties, "directory");
|
|
28
|
-
if (directoryProperty?.value.type !== "JSONLiteral" || typeof directoryProperty.value.value !== "string") return;
|
|
29
|
-
const directoryValue = directoryProperty.value.value;
|
|
30
|
-
const fileDirectory = path.normalize(path.dirname(context.filename));
|
|
31
|
-
let repositoryRoot;
|
|
32
|
-
if (repoRootCache && fileDirectory.startsWith(repoRootCache)) repositoryRoot = repoRootCache;
|
|
33
|
-
else {
|
|
34
|
-
repositoryRoot = findRootSync(fileDirectory);
|
|
35
|
-
if (repositoryRoot) repoRootCache = path.normalize(repositoryRoot);
|
|
36
|
-
}
|
|
37
|
-
if (repositoryRoot) {
|
|
38
|
-
const expected = path.relative(repositoryRoot, fileDirectory).replaceAll(path.sep, sep);
|
|
39
|
-
if (expected !== directoryValue) context.report({
|
|
40
|
-
messageId: "mismatched",
|
|
41
|
-
node: directoryProperty.value,
|
|
42
|
-
suggest: [{
|
|
43
|
-
data: { expected },
|
|
44
|
-
fix(fixer) {
|
|
45
|
-
return fixer.replaceText(directoryProperty.value, `"${expected}"`);
|
|
46
|
-
},
|
|
47
|
-
messageId: "replace"
|
|
48
|
-
}]
|
|
49
|
-
});
|
|
50
|
-
} else if (!pathEndsWith(fileDirectory, path.normalize(directoryValue))) context.report({
|
|
51
|
-
messageId: "mismatched",
|
|
52
|
-
node: directoryProperty.value
|
|
53
|
-
});
|
|
54
|
-
} };
|
|
55
|
-
},
|
|
56
|
-
meta: {
|
|
57
|
-
docs: {
|
|
58
|
-
category: "Best Practices",
|
|
59
|
-
description: "Enforce that if repository directory is specified, it matches the path to the package.json file",
|
|
60
|
-
recommended: true
|
|
61
|
-
},
|
|
62
|
-
hasSuggestions: true,
|
|
63
|
-
messages: {
|
|
64
|
-
mismatched: "Directory does not match package.json directory.",
|
|
65
|
-
replace: "Replace with '{{ expected }}'."
|
|
66
|
-
},
|
|
67
|
-
schema: [],
|
|
68
|
-
type: "suggestion"
|
|
69
|
-
},
|
|
70
|
-
name: "valid-repository-directory"
|
|
71
|
-
});
|
|
72
|
-
//#endregion
|
|
73
|
-
export { rule };
|
package/lib/types/estree.d.mts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PackageJsonRuleModule } from "../createRule.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/createSimpleRequirePropertyRule.d.ts
|
|
4
|
-
interface CreateRequirePropertyRuleOptions {
|
|
5
|
-
/**
|
|
6
|
-
* The category for this rule.
|
|
7
|
-
*/
|
|
8
|
-
category?: 'Publishable' | (string & {});
|
|
9
|
-
/** The value to use when fixing a violation when this property is missing */
|
|
10
|
-
fixValue?: unknown;
|
|
11
|
-
/**
|
|
12
|
-
* The default value of `ignorePrivate` rule option.
|
|
13
|
-
*/
|
|
14
|
-
ignorePrivateDefault?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Whether the rule should be included in the recommended config.
|
|
17
|
-
*/
|
|
18
|
-
isRecommended?: boolean;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Given a top-level property name, create a rule that requires that property to be present.
|
|
22
|
-
* Optionally, include it in the recommended config.
|
|
23
|
-
* Note: this will only create a basic require rule, with no options. If you need
|
|
24
|
-
* to create a more complex rule, create it in its own file.
|
|
25
|
-
*/
|
|
26
|
-
declare const createSimpleRequirePropertyRule: (propertyName: string, {
|
|
27
|
-
category,
|
|
28
|
-
fixValue,
|
|
29
|
-
ignorePrivateDefault,
|
|
30
|
-
isRecommended
|
|
31
|
-
}?: CreateRequirePropertyRuleOptions) => {
|
|
32
|
-
rule: PackageJsonRuleModule<[] | [({
|
|
33
|
-
ignorePrivate: boolean;
|
|
34
|
-
} | undefined)?], [] | [{
|
|
35
|
-
readonly additionalProperties: false;
|
|
36
|
-
readonly properties: {
|
|
37
|
-
readonly ignorePrivate: {
|
|
38
|
-
readonly default: boolean;
|
|
39
|
-
readonly description: "Determines if this rule should be enforced when the package's `private` property is `true`.";
|
|
40
|
-
readonly type: "boolean";
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
readonly type: "object";
|
|
44
|
-
}]>;
|
|
45
|
-
ruleName: string;
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { CreateRequirePropertyRuleOptions, createSimpleRequirePropertyRule };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { isJSONStringLiteral } from "./predicates/isJSONStringLiteral.mjs";
|
|
2
|
-
import { createRule } from "../createRule.mjs";
|
|
3
|
-
//#region src/utils/createSimpleRequirePropertyRule.ts
|
|
4
|
-
/**
|
|
5
|
-
* Given a top-level property name, create a rule that requires that property to be present.
|
|
6
|
-
* Optionally, include it in the recommended config.
|
|
7
|
-
* Note: this will only create a basic require rule, with no options. If you need
|
|
8
|
-
* to create a more complex rule, create it in its own file.
|
|
9
|
-
*/
|
|
10
|
-
const createSimpleRequirePropertyRule = (propertyName, { category, fixValue, ignorePrivateDefault = false, isRecommended } = {}) => {
|
|
11
|
-
const ruleName = `require-${propertyName}`;
|
|
12
|
-
return {
|
|
13
|
-
rule: createRule({
|
|
14
|
-
create(context) {
|
|
15
|
-
const enforceForPrivate = context.settings.packageJson?.enforceForPrivate;
|
|
16
|
-
const ignorePrivate = context.options[0]?.ignorePrivate ?? (typeof enforceForPrivate === "boolean" ? !enforceForPrivate : ignorePrivateDefault);
|
|
17
|
-
return { "Program > JSONExpressionStatement > JSONObjectExpression"(node) {
|
|
18
|
-
if (ignorePrivate && node.properties.some((property) => isJSONStringLiteral(property.key) && property.key.value === "private" && property.value.type === "JSONLiteral" && property.value.value === true)) return;
|
|
19
|
-
if (node.properties.every((property) => !(isJSONStringLiteral(property.key) && property.key.value === propertyName))) {
|
|
20
|
-
const resolvedValue = typeof fixValue === "function" ? fixValue() : fixValue;
|
|
21
|
-
context.report({
|
|
22
|
-
data: { property: propertyName },
|
|
23
|
-
fix: resolvedValue === void 0 ? void 0 : function* (fixer) {
|
|
24
|
-
yield fixer.insertTextAfterRange([0, 1], `\n "${propertyName}": ${JSON.stringify(resolvedValue, null, 2).split("\n").join("\n ")}`);
|
|
25
|
-
yield node.properties.length > 0 ? fixer.insertTextAfterRange([0, 1], ",") : fixer.insertTextAfterRange([0, 1], "\n");
|
|
26
|
-
},
|
|
27
|
-
loc: {
|
|
28
|
-
column: 0,
|
|
29
|
-
line: 1
|
|
30
|
-
},
|
|
31
|
-
messageId: "missing"
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
} };
|
|
35
|
-
},
|
|
36
|
-
meta: {
|
|
37
|
-
docs: {
|
|
38
|
-
category,
|
|
39
|
-
description: `Requires the \`${propertyName}\` property to be present.`,
|
|
40
|
-
recommended: isRecommended,
|
|
41
|
-
ruleGroup: "require-properties"
|
|
42
|
-
},
|
|
43
|
-
fixable: fixValue === void 0 ? void 0 : "code",
|
|
44
|
-
messages: { missing: "Property '{{property}}' is required." },
|
|
45
|
-
schema: propertyName === "private" ? [] : [{
|
|
46
|
-
additionalProperties: false,
|
|
47
|
-
properties: { ignorePrivate: {
|
|
48
|
-
default: ignorePrivateDefault,
|
|
49
|
-
description: "Determines if this rule should be enforced when the package's `private` property is `true`.",
|
|
50
|
-
type: "boolean"
|
|
51
|
-
} },
|
|
52
|
-
type: "object"
|
|
53
|
-
}],
|
|
54
|
-
type: "suggestion"
|
|
55
|
-
},
|
|
56
|
-
name: ruleName
|
|
57
|
-
}),
|
|
58
|
-
ruleName
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
//#endregion
|
|
62
|
-
export { createSimpleRequirePropertyRule };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageJsonRuleModule } from "../createRule.mjs";
|
|
2
|
-
import { Result } from "package-json-validator";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/createSimpleValidPropertyRule.d.ts
|
|
5
|
-
type ValidationFunction = (value: unknown) => Result;
|
|
6
|
-
/**
|
|
7
|
-
* Given a top-level property name, and a validation function, create a rule that validates the property using the validation function.
|
|
8
|
-
* These rules will always be included in the recommended config.
|
|
9
|
-
* Note: this will only create a basic validation rule, with no options. If you need
|
|
10
|
-
* to create a more complex rule, create it in its own file.
|
|
11
|
-
*/
|
|
12
|
-
declare const createSimpleValidPropertyRule: (propertyName: string, validationFunction: ValidationFunction, aliases?: string[]) => {
|
|
13
|
-
rule: PackageJsonRuleModule<[], []>;
|
|
14
|
-
ruleName: string;
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { ValidationFunction, createSimpleValidPropertyRule };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../createRule.mjs";
|
|
2
|
-
//#region src/utils/createSimpleValidPropertyRule.ts
|
|
3
|
-
/**
|
|
4
|
-
* Given a top-level property name, and a validation function, create a rule that validates the property using the validation function.
|
|
5
|
-
* These rules will always be included in the recommended config.
|
|
6
|
-
* Note: this will only create a basic validation rule, with no options. If you need
|
|
7
|
-
* to create a more complex rule, create it in its own file.
|
|
8
|
-
*/
|
|
9
|
-
const createSimpleValidPropertyRule = (propertyName, validationFunction, aliases = []) => {
|
|
10
|
-
const ruleName = `valid-${propertyName}`;
|
|
11
|
-
const propertyNames = [propertyName, ...aliases];
|
|
12
|
-
return {
|
|
13
|
-
rule: createRule({
|
|
14
|
-
create(context) {
|
|
15
|
-
const reportIssues = (result, node) => {
|
|
16
|
-
if (result.errorMessages.length === 0) return;
|
|
17
|
-
if (result.issues.length) for (const issue of result.issues) context.report({
|
|
18
|
-
data: { error: issue.message },
|
|
19
|
-
messageId: "validationError",
|
|
20
|
-
node
|
|
21
|
-
});
|
|
22
|
-
const childrenWithIssues = result.childResults.filter((childResult) => childResult.errorMessages.length);
|
|
23
|
-
if (node.type === "JSONObjectExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
24
|
-
const childNode = node.properties[childResult.index];
|
|
25
|
-
reportIssues(childResult, childNode.value);
|
|
26
|
-
}
|
|
27
|
-
else if (node.type === "JSONArrayExpression" && childrenWithIssues.length) for (const childResult of childrenWithIssues) {
|
|
28
|
-
const childNode = node.elements[childResult.index];
|
|
29
|
-
if (childNode) reportIssues(childResult, childNode);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return propertyNames.reduce((acc, name) => {
|
|
33
|
-
acc[`Program > JSONExpressionStatement > JSONObjectExpression > JSONProperty[key.value=${name}]`] = (node) => {
|
|
34
|
-
const valueNode = node.value;
|
|
35
|
-
reportIssues(validationFunction(JSON.parse(context.sourceCode.getText(valueNode))), valueNode);
|
|
36
|
-
};
|
|
37
|
-
return acc;
|
|
38
|
-
}, {});
|
|
39
|
-
},
|
|
40
|
-
meta: {
|
|
41
|
-
docs: {
|
|
42
|
-
category: "Best Practices",
|
|
43
|
-
description: `Enforce that the \`${propertyName}\`${aliases.length ? ` (also ${aliases.map((alias) => `\`${alias}\``).join(", ")})` : ""} property is valid.`,
|
|
44
|
-
recommended: true,
|
|
45
|
-
ruleGroup: "valid-properties"
|
|
46
|
-
},
|
|
47
|
-
messages: { validationError: `Invalid ${propertyName}: {{ error }}` },
|
|
48
|
-
schema: [],
|
|
49
|
-
type: "problem"
|
|
50
|
-
},
|
|
51
|
-
name: ruleName
|
|
52
|
-
}),
|
|
53
|
-
ruleName
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
//#endregion
|
|
57
|
-
export { createSimpleValidPropertyRule };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AST } from "jsonc-eslint-parser";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/findPropertyWithKeyValue.d.ts
|
|
4
|
-
type JSONPropertyWithKeyAndValue<Value extends string> = AST.JSONProperty & {
|
|
5
|
-
key: AST.JSONStringLiteral;
|
|
6
|
-
value: Value;
|
|
7
|
-
};
|
|
8
|
-
declare function findPropertyWithKeyValue<Value extends string>(properties: AST.JSONProperty[], value: Value): JSONPropertyWithKeyAndValue<Value> | undefined;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { JSONPropertyWithKeyAndValue, findPropertyWithKeyValue };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/utils/findPropertyWithKeyValue.ts
|
|
2
|
-
function findPropertyWithKeyValue(properties, value) {
|
|
3
|
-
return properties.find((property) => property.key.type === "JSONLiteral" && property.key.value === value);
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { findPropertyWithKeyValue };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/utils/formatErrors.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Formats an array of error messages into a single string.
|
|
4
|
-
* When there is more than one error, the errors will be formatted as a list,
|
|
5
|
-
* starting on a new line.
|
|
6
|
-
*/
|
|
7
|
-
declare const formatErrors: (errors: string[]) => string;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { formatErrors };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/utils/formatErrors.ts
|
|
2
|
-
/**
|
|
3
|
-
* Formats an array of error messages into a single string.
|
|
4
|
-
* When there is more than one error, the errors will be formatted as a list,
|
|
5
|
-
* starting on a new line.
|
|
6
|
-
*/
|
|
7
|
-
const formatErrors = (errors) => {
|
|
8
|
-
if (errors.length === 0) return "";
|
|
9
|
-
return errors.length > 1 ? ["", ...errors].join("\n - ") : errors[0];
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { formatErrors };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
|
-
//#region src/utils/git/getGitAuthor.ts
|
|
3
|
-
let cachedAuthor;
|
|
4
|
-
const getGitAuthor = () => {
|
|
5
|
-
if (cachedAuthor === null) return;
|
|
6
|
-
else if (cachedAuthor !== void 0) return cachedAuthor;
|
|
7
|
-
try {
|
|
8
|
-
const name = execFileSync("git", [
|
|
9
|
-
"config",
|
|
10
|
-
"--get",
|
|
11
|
-
"user.name"
|
|
12
|
-
], { encoding: "utf8" }).trim();
|
|
13
|
-
const email = execFileSync("git", [
|
|
14
|
-
"config",
|
|
15
|
-
"--get",
|
|
16
|
-
"user.email"
|
|
17
|
-
], { encoding: "utf8" }).trim();
|
|
18
|
-
cachedAuthor = {
|
|
19
|
-
name,
|
|
20
|
-
...email && { email }
|
|
21
|
-
};
|
|
22
|
-
} catch {
|
|
23
|
-
cachedAuthor = null;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
return cachedAuthor;
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { getGitAuthor };
|
package/lib/utils/git/index.mjs
DELETED