eslint-plugin-package-json 1.4.0 → 1.5.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 (37) hide show
  1. package/README.md +2 -2
  2. package/lib/createRule.d.mts +9 -9
  3. package/lib/createRule.mjs +1 -1
  4. package/lib/plugin.mjs +6 -4
  5. package/lib/rules/exports-subpaths-style.mjs +1 -1
  6. package/lib/rules/no-local-dependencies.mjs +1 -1
  7. package/lib/rules/no-redundant-files.mjs +2 -1
  8. package/lib/rules/no-redundant-publishConfig.mjs +1 -1
  9. package/lib/rules/repository-shorthand.mjs +1 -1
  10. package/lib/rules/require-properties.mjs +2 -1
  11. package/lib/rules/restrict-dependency-ranges.mjs +1 -1
  12. package/lib/rules/restrict-private-properties.mjs +1 -1
  13. package/lib/rules/restrict-top-level-properties.mjs +1 -1
  14. package/lib/rules/sort-collections.d.mts +1 -1
  15. package/lib/rules/specify-peers-locally.mjs +1 -1
  16. package/lib/rules/unique-dependencies.mjs +2 -1
  17. package/lib/rules/valid-author.d.mts +6 -0
  18. package/lib/rules/valid-author.mjs +59 -0
  19. package/lib/rules/valid-peerDependenciesMeta-relationship.mjs +1 -1
  20. package/lib/rules/valid-properties.mjs +1 -2
  21. package/lib/utils/createSimpleRequirePropertyRule.mjs +16 -13
  22. package/lib/utils/git/getGitAuthor.d.mts +8 -0
  23. package/lib/utils/git/getGitAuthor.mjs +29 -0
  24. package/lib/utils/git/index.d.mts +2 -0
  25. package/lib/utils/git/index.mjs +2 -0
  26. package/lib/utils/predicates/index.d.mts +4 -0
  27. package/lib/utils/predicates/index.mjs +4 -0
  28. package/lib/utils/predicates/isJSONStringLiteral.d.mts +6 -0
  29. package/lib/utils/predicates/isJSONStringLiteral.mjs +6 -0
  30. package/lib/utils/predicates/isNotNullish.d.mts +4 -0
  31. package/lib/utils/predicates/isNotNullish.mjs +6 -0
  32. package/lib/utils/predicates/isPackageJson.d.mts +4 -0
  33. package/lib/utils/{isPackageJson.mjs → predicates/isPackageJson.mjs} +1 -1
  34. package/package.json +3 -3
  35. package/lib/utils/isPackageJson.d.mts +0 -4
  36. package/lib/utils/predicates.d.mts +0 -7
  37. package/lib/utils/predicates.mjs +0 -9
package/README.md CHANGED
@@ -65,7 +65,7 @@ This group of rules allows you to require that the associated top-level property
65
65
 
66
66
  | Name | Description | 💼 | 🔧 | 💡 |
67
67
  | :--------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------- | :---- | :-- | :-- |
68
- | [require-author](https://eslint-plugin-package-json.dev/rules/require-properties/require-author) | Requires the `author` property to be present. | | | |
68
+ | [require-author](https://eslint-plugin-package-json.dev/rules/require-properties/require-author) | Requires the `author` property to be present. | | 🔧 | |
69
69
  | [require-bin](https://eslint-plugin-package-json.dev/rules/require-properties/require-bin) | Requires the `bin` property to be present. | | | |
70
70
  | [require-browser](https://eslint-plugin-package-json.dev/rules/require-properties/require-browser) | Requires the `browser` property to be present. | | | |
71
71
  | [require-bugs](https://eslint-plugin-package-json.dev/rules/require-properties/require-bugs) | Requires the `bugs` property to be present. | | | |
@@ -111,7 +111,7 @@ This group of rules allows you to enforce that the value of the associated top-l
111
111
 
112
112
  | Name                       | Description | 💼 | 🔧 | 💡 |
113
113
  | :--------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------ | :---- | :-- | :-- |
114
- | [valid-author](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-author) | Enforce that the `author` property is valid. | ✅ 📦 | | |
114
+ | [valid-author](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-author) | Enforce that the `author` property is valid. | ✅ 📦 | 🔧 | |
115
115
  | [valid-bin](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-bin) | Enforce that the `bin` property is valid. | ✅ 📦 | | |
116
116
  | [valid-browser](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-browser) | Enforce that the `browser` property is valid. | ✅ 📦 | | |
117
117
  | [valid-bugs](https://eslint-plugin-package-json.dev/rules/valid-properties/valid-bugs) | Enforce that the `bugs` property is valid. | ✅ 📦 | | |
@@ -5,17 +5,17 @@ import { AST, RuleListener } from "jsonc-eslint-parser";
5
5
  import { AST as AST$1, Rule, SourceCode } from "eslint";
6
6
 
7
7
  //#region src/createRule.d.ts
8
- type JsonAstBodyExpression = Expression & {
9
- properties: JsonAstBodyProperty[];
8
+ type ASTBodyExpression = Expression & {
9
+ properties: ASTBodyProperty[];
10
10
  };
11
- type JsonAstBodyProperty = AST.JSONProperty & {
11
+ type ASTBodyProperty = AST.JSONProperty & {
12
12
  value: string;
13
13
  };
14
- interface JsonAstBodyStatement extends ExpressionStatement {
15
- expression: JsonAstBodyExpression;
14
+ interface ASTBodyStatement extends ExpressionStatement {
15
+ expression: ASTBodyExpression;
16
16
  }
17
- interface PackageJsonAst extends AST$1.Program {
18
- body: [JsonAstBodyStatement];
17
+ interface PackageAST extends AST$1.Program {
18
+ body: [ASTBodyStatement];
19
19
  }
20
20
  interface PackageJsonPluginSettings {
21
21
  /**
@@ -45,7 +45,7 @@ interface PackageJsonRuleModule<Options extends unknown[] = unknown[], Schema ex
45
45
  };
46
46
  }
47
47
  interface PackageJsonSourceCode extends SourceCode {
48
- ast: PackageJsonAst;
48
+ ast: PackageAST;
49
49
  }
50
50
  type InferJsonSchemasTupleType<T extends JSONSchema[]> = { [K in keyof T]?: FromSchema<T[K]> };
51
51
  /**
@@ -56,4 +56,4 @@ declare function createRule<OptionsOverride extends unknown[] = never, const Sch
56
56
  name: string;
57
57
  }): PackageJsonRuleModule<_OptionsResolved, Schema>;
58
58
  //#endregion
59
- export { JsonAstBodyExpression, JsonAstBodyProperty, JsonAstBodyStatement, PackageJsonAst, PackageJsonPluginSettings, PackageJsonRuleContext, PackageJsonRuleModule, PackageJsonSourceCode, createRule };
59
+ export { ASTBodyExpression, ASTBodyProperty, ASTBodyStatement, PackageAST, PackageJsonPluginSettings, PackageJsonRuleContext, PackageJsonRuleModule, PackageJsonSourceCode, createRule };
@@ -1,4 +1,4 @@
1
- import { isPackageJson } from "./utils/isPackageJson.mjs";
1
+ import { isPackageJson } from "./utils/predicates/isPackageJson.mjs";
2
2
  //#region src/createRule.ts
3
3
  /**
4
4
  * Rule options type is inferred from the JSON schema by [json-schema-to-ts](https://www.npmjs.com/package/json-schema-to-ts).
package/lib/plugin.mjs CHANGED
@@ -15,9 +15,10 @@ import { rule as rule$12 } from "./rules/scripts-name-casing.mjs";
15
15
  import { rule as rule$13 } from "./rules/sort-collections.mjs";
16
16
  import { rule as rule$14 } from "./rules/specify-peers-locally.mjs";
17
17
  import { rule as rule$15 } from "./rules/unique-dependencies.mjs";
18
- import { rule as rule$16 } from "./rules/valid-peerDependenciesMeta-relationship.mjs";
18
+ import { rule as rule$16 } from "./rules/valid-author.mjs";
19
+ import { rule as rule$17 } from "./rules/valid-peerDependenciesMeta-relationship.mjs";
19
20
  import { rules as rules$2 } from "./rules/valid-properties.mjs";
20
- import { rule as rule$17 } from "./rules/valid-repository-directory.mjs";
21
+ import { rule as rule$18 } from "./rules/valid-repository-directory.mjs";
21
22
  import { createRequire } from "node:module";
22
23
  import * as parserJsonc from "jsonc-eslint-parser";
23
24
  //#region src/plugin.ts
@@ -40,9 +41,10 @@ const rules = {
40
41
  "sort-collections": rule$13,
41
42
  "specify-peers-locally": rule$14,
42
43
  "unique-dependencies": rule$15,
44
+ "valid-author": rule$16,
43
45
  ...rules$2,
44
- "valid-peerDependenciesMeta-relationship": rule$16,
45
- "valid-repository-directory": rule$17
46
+ "valid-peerDependenciesMeta-relationship": rule$17,
47
+ "valid-repository-directory": rule$18
46
48
  };
47
49
  const recommendedRules = { ...Object.fromEntries(Object.entries(rules).filter(([, rule]) => rule.meta.docs?.recommended).map(([name]) => ["package-json/" + name, "error"])) };
48
50
  const recommendedPublishableRules = {
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  //#region src/rules/exports-subpaths-style.ts
4
4
  function isImplicitFormat(node) {
5
5
  if (node.type === "JSONLiteral") return true;
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  //#region src/rules/no-local-dependencies.ts
4
4
  const isLocalDependency = (value) => value.startsWith("file:") || value.startsWith("link:") || value.startsWith("./") || value.startsWith("../") || value.startsWith(".\\") || value.startsWith("..\\");
5
5
  const rule = createRule({
@@ -1,5 +1,6 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
2
+ import { isNotNullish } from "../utils/predicates/isNotNullish.mjs";
1
3
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral, isNotNullish } from "../utils/predicates.mjs";
3
4
  import { fixRemoveArrayElement } from "eslint-fix-utils";
4
5
  //#region src/rules/no-redundant-files.ts
5
6
  const defaultFiles = [
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import { fixRemoveObjectProperty } from "eslint-fix-utils";
4
4
  //#region src/rules/no-redundant-publishConfig.ts
5
5
  const rule = createRule({
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import { findPropertyWithKeyValue } from "../utils/findPropertyWithKeyValue.mjs";
4
4
  //#region src/rules/repository-shorthand.ts
5
5
  const providerRegexes = {
@@ -1,7 +1,8 @@
1
1
  import { createSimpleRequirePropertyRule } from "../utils/createSimpleRequirePropertyRule.mjs";
2
+ import { getGitAuthor } from "../utils/git/getGitAuthor.mjs";
2
3
  //#region src/rules/require-properties.ts
3
4
  const propertyConfig = [
4
- ["author"],
5
+ ["author", { fixValue: getGitAuthor }],
5
6
  ["bin"],
6
7
  ["browser"],
7
8
  ["bugs", { ignorePrivateDefault: true }],
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import semver from "semver";
4
4
  //#region src/rules/restrict-dependency-ranges.ts
5
5
  const DEPENDENCY_TYPES = [
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import { fixRemoveObjectProperty } from "eslint-fix-utils";
4
4
  //#region src/rules/restrict-private-properties.ts
5
5
  const defaultBlockedProperties = ["files", "publishConfig"];
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import { fixRemoveObjectProperty } from "eslint-fix-utils";
4
4
  //#region src/rules/restrict-top-level-properties.ts
5
5
  const rule = createRule({
@@ -2,8 +2,8 @@ import { PackageJsonRuleModule } from "../createRule.mjs";
2
2
 
3
3
  //#region src/rules/sort-collections.d.ts
4
4
  declare const rule: PackageJsonRuleModule<[((string | {
5
- key: string;
6
5
  order: string[];
6
+ key: string;
7
7
  })[] | undefined)?], [{
8
8
  readonly description: "Array of package properties to require sorting. Provide a string to sort that collection lexicographically (lifecycle-aware for `scripts`), or an object to sort it by a specified order.";
9
9
  readonly items: {
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  //#region src/rules/specify-peers-locally.ts
4
4
  const rule = createRule({
5
5
  create(context) {
@@ -1,5 +1,6 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
2
+ import { isNotNullish } from "../utils/predicates/isNotNullish.mjs";
1
3
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral, isNotNullish } from "../utils/predicates.mjs";
3
4
  import { fixRemoveArrayElement, fixRemoveObjectProperty } from "eslint-fix-utils";
4
5
  //#region src/rules/unique-dependencies.ts
5
6
  const dependencyPropertyNames = new Set([
@@ -0,0 +1,6 @@
1
+ import { PackageJsonRuleModule } from "../createRule.mjs";
2
+
3
+ //#region src/rules/valid-author.d.ts
4
+ declare const rule: PackageJsonRuleModule<[], []>;
5
+ //#endregion
6
+ export { rule };
@@ -0,0 +1,59 @@
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,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "../utils/predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "../utils/predicates.mjs";
3
3
  import { fixRemoveObjectProperty } from "eslint-fix-utils";
4
4
  //#region src/rules/valid-peerDependenciesMeta-relationship.ts
5
5
  const rule = createRule({
@@ -1,8 +1,7 @@
1
1
  import { createSimpleValidPropertyRule } from "../utils/createSimpleValidPropertyRule.mjs";
2
- import { validateAuthor, 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";
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
3
  /** All basic valid- flavor rules */
4
4
  const rules = Object.fromEntries([
5
- ["author", validateAuthor],
6
5
  ["bin", validateBin],
7
6
  ["browser", validateBrowser],
8
7
  ["bugs", validateBugs],
@@ -1,5 +1,5 @@
1
+ import { isJSONStringLiteral } from "./predicates/isJSONStringLiteral.mjs";
1
2
  import { createRule } from "../createRule.mjs";
2
- import { isJSONStringLiteral } from "./predicates.mjs";
3
3
  //#region src/utils/createSimpleRequirePropertyRule.ts
4
4
  /**
5
5
  * Given a top-level property name, create a rule that requires that property to be present.
@@ -16,18 +16,21 @@ const createSimpleRequirePropertyRule = (propertyName, { category, fixValue, ign
16
16
  const ignorePrivate = context.options[0]?.ignorePrivate ?? (typeof enforceForPrivate === "boolean" ? !enforceForPrivate : ignorePrivateDefault);
17
17
  return { "Program > JSONExpressionStatement > JSONObjectExpression"(node) {
18
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))) context.report({
20
- data: { property: propertyName },
21
- fix: fixValue === void 0 ? void 0 : function* (fixer) {
22
- yield fixer.insertTextAfterRange([0, 1], `\n "${propertyName}": ${JSON.stringify(fixValue)}`);
23
- yield node.properties.length > 0 ? fixer.insertTextAfterRange([0, 1], ",") : fixer.insertTextAfterRange([0, 1], "\n");
24
- },
25
- loc: {
26
- column: 0,
27
- line: 1
28
- },
29
- messageId: "missing"
30
- });
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
+ }
31
34
  } };
32
35
  },
33
36
  meta: {
@@ -0,0 +1,8 @@
1
+ //#region src/utils/git/getGitAuthor.d.ts
2
+ interface Author {
3
+ email?: string;
4
+ name: string;
5
+ }
6
+ declare const getGitAuthor: () => Author | undefined;
7
+ //#endregion
8
+ export { getGitAuthor };
@@ -0,0 +1,29 @@
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 };
@@ -0,0 +1,2 @@
1
+ import { getGitAuthor } from "./getGitAuthor.mjs";
2
+ export { getGitAuthor };
@@ -0,0 +1,2 @@
1
+ import { getGitAuthor } from "./getGitAuthor.mjs";
2
+ export { getGitAuthor };
@@ -0,0 +1,4 @@
1
+ import { isJSONStringLiteral } from "./isJSONStringLiteral.mjs";
2
+ import { isNotNullish } from "./isNotNullish.mjs";
3
+ import { isPackageJson } from "./isPackageJson.mjs";
4
+ export { isJSONStringLiteral, isNotNullish, isPackageJson };
@@ -0,0 +1,4 @@
1
+ import { isJSONStringLiteral } from "./isJSONStringLiteral.mjs";
2
+ import { isNotNullish } from "./isNotNullish.mjs";
3
+ import { isPackageJson } from "./isPackageJson.mjs";
4
+ export { isJSONStringLiteral, isNotNullish, isPackageJson };
@@ -0,0 +1,6 @@
1
+ import { AST } from "jsonc-eslint-parser";
2
+
3
+ //#region src/utils/predicates/isJSONStringLiteral.d.ts
4
+ declare function isJSONStringLiteral(node: AST.JSONNode): node is AST.JSONStringLiteral;
5
+ //#endregion
6
+ export { isJSONStringLiteral };
@@ -0,0 +1,6 @@
1
+ //#region src/utils/predicates/isJSONStringLiteral.ts
2
+ function isJSONStringLiteral(node) {
3
+ return node.type === "JSONLiteral" && typeof node.value === "string";
4
+ }
5
+ //#endregion
6
+ export { isJSONStringLiteral };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/predicates/isNotNullish.d.ts
2
+ declare function isNotNullish<T extends NonNullable<unknown>>(value: null | T | undefined): value is T;
3
+ //#endregion
4
+ export { isNotNullish };
@@ -0,0 +1,6 @@
1
+ //#region src/utils/predicates/isNotNullish.ts
2
+ function isNotNullish(value) {
3
+ return value !== null && value !== void 0;
4
+ }
5
+ //#endregion
6
+ export { isNotNullish };
@@ -0,0 +1,4 @@
1
+ //#region src/utils/predicates/isPackageJson.d.ts
2
+ declare const isPackageJson: (filePath: string) => boolean;
3
+ //#endregion
4
+ export { isPackageJson };
@@ -1,4 +1,4 @@
1
- //#region src/utils/isPackageJson.ts
1
+ //#region src/utils/predicates/isPackageJson.ts
2
2
  const isPackageJson = (filePath) => /(?:^|[/\\])package.json$/.test(filePath);
3
3
  //#endregion
4
4
  export { isPackageJson };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-package-json",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Rules for consistent, readable, and valid package.json files. 🗂️",
5
5
  "homepage": "https://github.com/michaelfaith/eslint-plugin-package-json#readme",
6
6
  "bugs": {
@@ -82,11 +82,11 @@
82
82
  "eslint-plugin-node-dependencies": "2.2.0",
83
83
  "eslint-plugin-perfectionist": "5.9.0",
84
84
  "eslint-plugin-regexp": "3.1.0",
85
- "eslint-plugin-unicorn": "66.0.0",
85
+ "eslint-plugin-unicorn": "67.0.0",
86
86
  "eslint-plugin-yml": "3.4.0",
87
87
  "jiti": "2.7.0",
88
88
  "json-schema-to-ts": "3.1.1",
89
- "knip": "6.16.0",
89
+ "knip": "6.17.1",
90
90
  "prettier": "3.8.4",
91
91
  "prettier-plugin-curly": "0.4.1",
92
92
  "prettier-plugin-packagejson": "3.0.2",
@@ -1,4 +0,0 @@
1
- //#region src/utils/isPackageJson.d.ts
2
- declare const isPackageJson: (filePath: string) => boolean;
3
- //#endregion
4
- export { isPackageJson };
@@ -1,7 +0,0 @@
1
- import { AST } from "jsonc-eslint-parser";
2
-
3
- //#region src/utils/predicates.d.ts
4
- declare function isJSONStringLiteral(node: AST.JSONNode): node is AST.JSONStringLiteral;
5
- declare function isNotNullish<T extends NonNullable<unknown>>(value: null | T | undefined): value is T;
6
- //#endregion
7
- export { isJSONStringLiteral, isNotNullish };
@@ -1,9 +0,0 @@
1
- //#region src/utils/predicates.ts
2
- function isJSONStringLiteral(node) {
3
- return node.type === "JSONLiteral" && typeof node.value === "string";
4
- }
5
- function isNotNullish(value) {
6
- return value !== null && value !== void 0;
7
- }
8
- //#endregion
9
- export { isJSONStringLiteral, isNotNullish };