eslint-plugin-package-json 0.21.1 → 0.23.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.
- package/README.md +2 -0
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +2 -2
- package/lib/index.mjs.map +1 -1
- package/lib/plugin.js +2 -0
- package/lib/plugin.js.map +1 -1
- package/lib/plugin.mjs +2 -0
- package/lib/plugin.mjs.map +1 -1
- package/lib/rules/require-properties.d.mts +9 -0
- package/lib/rules/require-properties.d.ts +9 -0
- package/lib/rules/require-properties.js +44 -0
- package/lib/rules/require-properties.js.map +1 -0
- package/lib/rules/require-properties.mjs +20 -0
- package/lib/rules/require-properties.mjs.map +1 -0
- package/lib/rules/valid-local-dependency.js +5 -14
- package/lib/rules/valid-local-dependency.js.map +1 -1
- package/lib/rules/valid-local-dependency.mjs +5 -14
- package/lib/rules/valid-local-dependency.mjs.map +1 -1
- package/lib/rules/valid-package-definition.js +1 -3
- package/lib/rules/valid-package-definition.js.map +1 -1
- package/lib/rules/valid-package-definition.mjs +2 -4
- package/lib/rules/valid-package-definition.mjs.map +1 -1
- package/lib/utils/createRequirePropertyRule.d.mts +15 -0
- package/lib/utils/createRequirePropertyRule.d.ts +15 -0
- package/lib/utils/createRequirePropertyRule.js +60 -0
- package/lib/utils/createRequirePropertyRule.js.map +1 -0
- package/lib/utils/createRequirePropertyRule.mjs +36 -0
- package/lib/utils/createRequirePropertyRule.mjs.map +1 -0
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -126,6 +126,8 @@ The default settings don't conflict, and Prettier plugins can quickly fix up ord
|
|
|
126
126
|
| [no-redundant-files](docs/rules/no-redundant-files.md) | Prevents adding unnecessary / redundant files. | | | 💡 | |
|
|
127
127
|
| [order-properties](docs/rules/order-properties.md) | Package properties must be declared in standard order | ✅ | 🔧 | | |
|
|
128
128
|
| [repository-shorthand](docs/rules/repository-shorthand.md) | Enforce either object or shorthand declaration for repository. | ✅ | 🔧 | | |
|
|
129
|
+
| [require-author](docs/rules/require-author.md) | Requires the `author` property to be present. | | | | |
|
|
130
|
+
| [require-version](docs/rules/require-version.md) | Requires the `version` property to be present. | ✅ | | | |
|
|
129
131
|
| [sort-collections](docs/rules/sort-collections.md) | Dependencies, scripts, and configuration values must be declared in alphabetical order. | ✅ | 🔧 | | |
|
|
130
132
|
| [unique-dependencies](docs/rules/unique-dependencies.md) | Checks a dependency isn't specified more than once (i.e. in `dependencies` and `devDependencies`) | ✅ | | 💡 | |
|
|
131
133
|
| [valid-local-dependency](docs/rules/valid-local-dependency.md) | Checks existence of local dependencies in the package.json | ✅ | | | |
|
package/lib/index.js
CHANGED
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
21
|
configs: () => configs,
|
|
22
|
-
default: () =>
|
|
22
|
+
default: () => index_default,
|
|
23
23
|
rules: () => rules
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var import_plugin = require("./plugin.js");
|
|
27
27
|
const rules = import_plugin.plugin.rules;
|
|
28
28
|
const configs = {
|
|
@@ -31,7 +31,7 @@ const configs = {
|
|
|
31
31
|
rules: import_plugin.recommendedRuleSettings
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
var
|
|
34
|
+
var index_default = import_plugin.plugin;
|
|
35
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
36
|
0 && (module.exports = {
|
|
37
37
|
configs,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { plugin, recommendedRuleSettings } from \"./plugin.js\";\n\nexport const rules = plugin.rules;\n\nexport const configs = {\n\trecommended: {\n\t\tplugins: [\"package-json\"],\n\t\trules: recommendedRuleSettings,\n\t},\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAEzC,MAAM,QAAQ,qBAAO;AAErB,MAAM,UAAU;AAAA,EACtB,aAAa;AAAA,IACZ,SAAS,CAAC,cAAc;AAAA,IACxB,OAAO;AAAA,EACR;AACD;AAEA,IAAO,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { plugin, recommendedRuleSettings } from \"./plugin.js\";\n\nexport const rules = plugin.rules;\n\nexport const configs = {\n\trecommended: {\n\t\tplugins: [\"package-json\"],\n\t\trules: recommendedRuleSettings,\n\t},\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAEzC,MAAM,QAAQ,qBAAO;AAErB,MAAM,UAAU;AAAA,EACtB,aAAa;AAAA,IACZ,SAAS,CAAC,cAAc;AAAA,IACxB,OAAO;AAAA,EACR;AACD;AAEA,IAAO,gBAAQ;","names":[]}
|
package/lib/index.mjs
CHANGED
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { plugin, recommendedRuleSettings } from \"./plugin.js\";\n\nexport const rules = plugin.rules;\n\nexport const configs = {\n\trecommended: {\n\t\tplugins: [\"package-json\"],\n\t\trules: recommendedRuleSettings,\n\t},\n};\n\nexport default plugin;\n"],"mappings":"AAAA,SAAS,QAAQ,+BAA+B;AAEzC,MAAM,QAAQ,OAAO;AAErB,MAAM,UAAU;AAAA,EACtB,aAAa;AAAA,IACZ,SAAS,CAAC,cAAc;AAAA,IACxB,OAAO;AAAA,EACR;AACD;AAEA,IAAO,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { plugin, recommendedRuleSettings } from \"./plugin.js\";\n\nexport const rules = plugin.rules;\n\nexport const configs = {\n\trecommended: {\n\t\tplugins: [\"package-json\"],\n\t\trules: recommendedRuleSettings,\n\t},\n};\n\nexport default plugin;\n"],"mappings":"AAAA,SAAS,QAAQ,+BAA+B;AAEzC,MAAM,QAAQ,OAAO;AAErB,MAAM,UAAU;AAAA,EACtB,aAAa;AAAA,IACZ,SAAS,CAAC,cAAc;AAAA,IACxB,OAAO;AAAA,EACR;AACD;AAEA,IAAO,gBAAQ;","names":[]}
|
package/lib/plugin.js
CHANGED
|
@@ -27,6 +27,7 @@ var import_no_empty_fields = require("./rules/no-empty-fields.js");
|
|
|
27
27
|
var import_no_redundant_files = require("./rules/no-redundant-files.js");
|
|
28
28
|
var import_order_properties = require("./rules/order-properties.js");
|
|
29
29
|
var import_repository_shorthand = require("./rules/repository-shorthand.js");
|
|
30
|
+
var import_require_properties = require("./rules/require-properties.js");
|
|
30
31
|
var import_sort_collections = require("./rules/sort-collections.js");
|
|
31
32
|
var import_unique_dependencies = require("./rules/unique-dependencies.js");
|
|
32
33
|
var import_valid_local_dependency = require("./rules/valid-local-dependency.js");
|
|
@@ -41,6 +42,7 @@ const rules = {
|
|
|
41
42
|
"no-empty-fields": import_no_empty_fields.rule,
|
|
42
43
|
"no-redundant-files": import_no_redundant_files.rule,
|
|
43
44
|
"order-properties": import_order_properties.rule,
|
|
45
|
+
...import_require_properties.rules,
|
|
44
46
|
"repository-shorthand": import_repository_shorthand.rule,
|
|
45
47
|
"sort-collections": import_sort_collections.rule,
|
|
46
48
|
"unique-dependencies": import_unique_dependencies.rule,
|
package/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { PackageJsonRuleModule } from \"./createRule.js\";\n\nimport { rule as noEmptyFields } from \"./rules/no-empty-fields.js\";\nimport { rule as noRedundantFiles } from \"./rules/no-redundant-files.js\";\nimport { rule as orderProperties } from \"./rules/order-properties.js\";\nimport { rule as preferRepositoryShorthand } from \"./rules/repository-shorthand.js\";\nimport { rule as sortCollections } from \"./rules/sort-collections.js\";\nimport { rule as uniqueDependencies } from \"./rules/unique-dependencies.js\";\nimport { rule as validLocalDependency } from \"./rules/valid-local-dependency.js\";\nimport { rule as validName } from \"./rules/valid-name.js\";\nimport { rule as validPackageDefinition } from \"./rules/valid-package-definition.js\";\nimport { rule as validRepositoryDirectory } from \"./rules/valid-repository-directory.js\";\nimport { rule as validVersion } from \"./rules/valid-version.js\";\n\nconst require = createRequire(import.meta.url || __filename);\n\nconst { name, version } = require(\"../package.json\") as {\n\tname: string;\n\tversion: string;\n};\n\nconst rules: Record<string, PackageJsonRuleModule> = {\n\t\"no-empty-fields\": noEmptyFields,\n\t\"no-redundant-files\": noRedundantFiles,\n\t\"order-properties\": orderProperties,\n\t\"repository-shorthand\": preferRepositoryShorthand,\n\t\"sort-collections\": sortCollections,\n\t\"unique-dependencies\": uniqueDependencies,\n\t\"valid-local-dependency\": validLocalDependency,\n\t\"valid-name\": validName,\n\t\"valid-package-definition\": validPackageDefinition,\n\t\"valid-repository-directory\": validRepositoryDirectory,\n\t\"valid-version\": validVersion,\n\n\t/** @deprecated use 'valid-package-definition' instead */\n\t\"valid-package-def\": {\n\t\t...validPackageDefinition,\n\t\tmeta: {\n\t\t\t...validPackageDefinition.meta,\n\t\t\tdeprecated: true,\n\t\t\tdocs: {\n\t\t\t\t...validPackageDefinition.meta.docs,\n\t\t\t\trecommended: false,\n\t\t\t},\n\t\t\treplacedBy: [\"valid-package-definition\"],\n\t\t},\n\t},\n};\n\nexport const plugin = {\n\tmeta: {\n\t\tname,\n\t\tversion,\n\t},\n\trules,\n};\n\nexport const recommendedRuleSettings = Object.fromEntries(\n\tObject.entries(rules)\n\t\t.filter(([, rule]) => rule.meta.docs?.recommended)\n\t\t.map(([name]) => [\"package-json/\" + name, \"error\" as const]),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA8B;AAI9B,6BAAsC;AACtC,gCAAyC;AACzC,8BAAwC;AACxC,kCAAkD;AAClD,8BAAwC;AACxC,iCAA2C;AAC3C,oCAA6C;AAC7C,wBAAkC;AAClC,sCAA+C;AAC/C,wCAAiD;AACjD,2BAAqC;
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { PackageJsonRuleModule } from \"./createRule.js\";\n\nimport { rule as noEmptyFields } from \"./rules/no-empty-fields.js\";\nimport { rule as noRedundantFiles } from \"./rules/no-redundant-files.js\";\nimport { rule as orderProperties } from \"./rules/order-properties.js\";\nimport { rule as preferRepositoryShorthand } from \"./rules/repository-shorthand.js\";\nimport { rules as requireRules } from \"./rules/require-properties.js\";\nimport { rule as sortCollections } from \"./rules/sort-collections.js\";\nimport { rule as uniqueDependencies } from \"./rules/unique-dependencies.js\";\nimport { rule as validLocalDependency } from \"./rules/valid-local-dependency.js\";\nimport { rule as validName } from \"./rules/valid-name.js\";\nimport { rule as validPackageDefinition } from \"./rules/valid-package-definition.js\";\nimport { rule as validRepositoryDirectory } from \"./rules/valid-repository-directory.js\";\nimport { rule as validVersion } from \"./rules/valid-version.js\";\n\nconst require = createRequire(import.meta.url || __filename);\n\nconst { name, version } = require(\"../package.json\") as {\n\tname: string;\n\tversion: string;\n};\n\nconst rules: Record<string, PackageJsonRuleModule> = {\n\t\"no-empty-fields\": noEmptyFields,\n\t\"no-redundant-files\": noRedundantFiles,\n\t\"order-properties\": orderProperties,\n\t...requireRules,\n\t\"repository-shorthand\": preferRepositoryShorthand,\n\t\"sort-collections\": sortCollections,\n\t\"unique-dependencies\": uniqueDependencies,\n\t\"valid-local-dependency\": validLocalDependency,\n\t\"valid-name\": validName,\n\t\"valid-package-definition\": validPackageDefinition,\n\t\"valid-repository-directory\": validRepositoryDirectory,\n\t\"valid-version\": validVersion,\n\n\t/** @deprecated use 'valid-package-definition' instead */\n\t\"valid-package-def\": {\n\t\t...validPackageDefinition,\n\t\tmeta: {\n\t\t\t...validPackageDefinition.meta,\n\t\t\tdeprecated: true,\n\t\t\tdocs: {\n\t\t\t\t...validPackageDefinition.meta.docs,\n\t\t\t\trecommended: false,\n\t\t\t},\n\t\t\treplacedBy: [\"valid-package-definition\"],\n\t\t},\n\t},\n};\n\nexport const plugin = {\n\tmeta: {\n\t\tname,\n\t\tversion,\n\t},\n\trules,\n};\n\nexport const recommendedRuleSettings = Object.fromEntries(\n\tObject.entries(rules)\n\t\t.filter(([, rule]) => rule.meta.docs?.recommended)\n\t\t.map(([name]) => [\"package-json/\" + name, \"error\" as const]),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA8B;AAI9B,6BAAsC;AACtC,gCAAyC;AACzC,8BAAwC;AACxC,kCAAkD;AAClD,gCAAsC;AACtC,8BAAwC;AACxC,iCAA2C;AAC3C,oCAA6C;AAC7C,wBAAkC;AAClC,sCAA+C;AAC/C,wCAAiD;AACjD,2BAAqC;AAfrC;AAiBA,MAAMA,eAAU,kCAAc,YAAY,OAAO,UAAU;AAE3D,MAAM,EAAE,MAAM,QAAQ,IAAIA,SAAQ,iBAAiB;AAKnD,MAAM,QAA+C;AAAA,EACpD,mBAAmB,uBAAAC;AAAA,EACnB,sBAAsB,0BAAAC;AAAA,EACtB,oBAAoB,wBAAAC;AAAA,EACpB,GAAG,0BAAAC;AAAA,EACH,wBAAwB,4BAAAC;AAAA,EACxB,oBAAoB,wBAAAC;AAAA,EACpB,uBAAuB,2BAAAC;AAAA,EACvB,0BAA0B,8BAAAC;AAAA,EAC1B,cAAc,kBAAAC;AAAA,EACd,4BAA4B,gCAAAC;AAAA,EAC5B,8BAA8B,kCAAAC;AAAA,EAC9B,iBAAiB,qBAAAC;AAAA;AAAA,EAGjB,qBAAqB;AAAA,IACpB,GAAG,gCAAAF;AAAA,IACH,MAAM;AAAA,MACL,GAAG,gCAAAA,KAAuB;AAAA,MAC1B,YAAY;AAAA,MACZ,MAAM;AAAA,QACL,GAAG,gCAAAA,KAAuB,KAAK;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,YAAY,CAAC,0BAA0B;AAAA,IACxC;AAAA,EACD;AACD;AAEO,MAAM,SAAS;AAAA,EACrB,MAAM;AAAA,IACL;AAAA,IACA;AAAA,EACD;AAAA,EACA;AACD;AAEO,MAAM,0BAA0B,OAAO;AAAA,EAC7C,OAAO,QAAQ,KAAK,EAClB,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,KAAK,KAAK,MAAM,WAAW,EAChD,IAAI,CAAC,CAACG,KAAI,MAAM,CAAC,kBAAkBA,OAAM,OAAgB,CAAC;AAC7D;","names":["require","noEmptyFields","noRedundantFiles","orderProperties","requireRules","preferRepositoryShorthand","sortCollections","uniqueDependencies","validLocalDependency","validName","validPackageDefinition","validRepositoryDirectory","validVersion","name"]}
|
package/lib/plugin.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { rule as noEmptyFields } from "./rules/no-empty-fields.js";
|
|
|
3
3
|
import { rule as noRedundantFiles } from "./rules/no-redundant-files.js";
|
|
4
4
|
import { rule as orderProperties } from "./rules/order-properties.js";
|
|
5
5
|
import { rule as preferRepositoryShorthand } from "./rules/repository-shorthand.js";
|
|
6
|
+
import { rules as requireRules } from "./rules/require-properties.js";
|
|
6
7
|
import { rule as sortCollections } from "./rules/sort-collections.js";
|
|
7
8
|
import { rule as uniqueDependencies } from "./rules/unique-dependencies.js";
|
|
8
9
|
import { rule as validLocalDependency } from "./rules/valid-local-dependency.js";
|
|
@@ -16,6 +17,7 @@ const rules = {
|
|
|
16
17
|
"no-empty-fields": noEmptyFields,
|
|
17
18
|
"no-redundant-files": noRedundantFiles,
|
|
18
19
|
"order-properties": orderProperties,
|
|
20
|
+
...requireRules,
|
|
19
21
|
"repository-shorthand": preferRepositoryShorthand,
|
|
20
22
|
"sort-collections": sortCollections,
|
|
21
23
|
"unique-dependencies": uniqueDependencies,
|
package/lib/plugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { PackageJsonRuleModule } from \"./createRule.js\";\n\nimport { rule as noEmptyFields } from \"./rules/no-empty-fields.js\";\nimport { rule as noRedundantFiles } from \"./rules/no-redundant-files.js\";\nimport { rule as orderProperties } from \"./rules/order-properties.js\";\nimport { rule as preferRepositoryShorthand } from \"./rules/repository-shorthand.js\";\nimport { rule as sortCollections } from \"./rules/sort-collections.js\";\nimport { rule as uniqueDependencies } from \"./rules/unique-dependencies.js\";\nimport { rule as validLocalDependency } from \"./rules/valid-local-dependency.js\";\nimport { rule as validName } from \"./rules/valid-name.js\";\nimport { rule as validPackageDefinition } from \"./rules/valid-package-definition.js\";\nimport { rule as validRepositoryDirectory } from \"./rules/valid-repository-directory.js\";\nimport { rule as validVersion } from \"./rules/valid-version.js\";\n\nconst require = createRequire(import.meta.url || __filename);\n\nconst { name, version } = require(\"../package.json\") as {\n\tname: string;\n\tversion: string;\n};\n\nconst rules: Record<string, PackageJsonRuleModule> = {\n\t\"no-empty-fields\": noEmptyFields,\n\t\"no-redundant-files\": noRedundantFiles,\n\t\"order-properties\": orderProperties,\n\t\"repository-shorthand\": preferRepositoryShorthand,\n\t\"sort-collections\": sortCollections,\n\t\"unique-dependencies\": uniqueDependencies,\n\t\"valid-local-dependency\": validLocalDependency,\n\t\"valid-name\": validName,\n\t\"valid-package-definition\": validPackageDefinition,\n\t\"valid-repository-directory\": validRepositoryDirectory,\n\t\"valid-version\": validVersion,\n\n\t/** @deprecated use 'valid-package-definition' instead */\n\t\"valid-package-def\": {\n\t\t...validPackageDefinition,\n\t\tmeta: {\n\t\t\t...validPackageDefinition.meta,\n\t\t\tdeprecated: true,\n\t\t\tdocs: {\n\t\t\t\t...validPackageDefinition.meta.docs,\n\t\t\t\trecommended: false,\n\t\t\t},\n\t\t\treplacedBy: [\"valid-package-definition\"],\n\t\t},\n\t},\n};\n\nexport const plugin = {\n\tmeta: {\n\t\tname,\n\t\tversion,\n\t},\n\trules,\n};\n\nexport const recommendedRuleSettings = Object.fromEntries(\n\tObject.entries(rules)\n\t\t.filter(([, rule]) => rule.meta.docs?.recommended)\n\t\t.map(([name]) => [\"package-json/\" + name, \"error\" as const]),\n);\n"],"mappings":"AAAA,SAAS,qBAAqB;AAI9B,SAAS,QAAQ,qBAAqB;AACtC,SAAS,QAAQ,wBAAwB;AACzC,SAAS,QAAQ,uBAAuB;AACxC,SAAS,QAAQ,iCAAiC;AAClD,SAAS,QAAQ,uBAAuB;AACxC,SAAS,QAAQ,0BAA0B;AAC3C,SAAS,QAAQ,4BAA4B;AAC7C,SAAS,QAAQ,iBAAiB;AAClC,SAAS,QAAQ,8BAA8B;AAC/C,SAAS,QAAQ,gCAAgC;AACjD,SAAS,QAAQ,oBAAoB;AAErC,MAAMA,WAAU,cAAc,YAAY,OAAO,UAAU;AAE3D,MAAM,EAAE,MAAM,QAAQ,IAAIA,SAAQ,iBAAiB;AAKnD,MAAM,QAA+C;AAAA,EACpD,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,cAAc;AAAA,EACd,4BAA4B;AAAA,EAC5B,8BAA8B;AAAA,EAC9B,iBAAiB;AAAA;AAAA,EAGjB,qBAAqB;AAAA,IACpB,GAAG;AAAA,IACH,MAAM;AAAA,MACL,GAAG,uBAAuB;AAAA,MAC1B,YAAY;AAAA,MACZ,MAAM;AAAA,QACL,GAAG,uBAAuB,KAAK;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,YAAY,CAAC,0BAA0B;AAAA,IACxC;AAAA,EACD;AACD;AAEO,MAAM,SAAS;AAAA,EACrB,MAAM;AAAA,IACL;AAAA,IACA;AAAA,EACD;AAAA,EACA;AACD;AAEO,MAAM,0BAA0B,OAAO;AAAA,EAC7C,OAAO,QAAQ,KAAK,EAClB,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,KAAK,KAAK,MAAM,WAAW,EAChD,IAAI,CAAC,CAACC,KAAI,MAAM,CAAC,kBAAkBA,OAAM,OAAgB,CAAC;AAC7D;","names":["require","name"]}
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport type { PackageJsonRuleModule } from \"./createRule.js\";\n\nimport { rule as noEmptyFields } from \"./rules/no-empty-fields.js\";\nimport { rule as noRedundantFiles } from \"./rules/no-redundant-files.js\";\nimport { rule as orderProperties } from \"./rules/order-properties.js\";\nimport { rule as preferRepositoryShorthand } from \"./rules/repository-shorthand.js\";\nimport { rules as requireRules } from \"./rules/require-properties.js\";\nimport { rule as sortCollections } from \"./rules/sort-collections.js\";\nimport { rule as uniqueDependencies } from \"./rules/unique-dependencies.js\";\nimport { rule as validLocalDependency } from \"./rules/valid-local-dependency.js\";\nimport { rule as validName } from \"./rules/valid-name.js\";\nimport { rule as validPackageDefinition } from \"./rules/valid-package-definition.js\";\nimport { rule as validRepositoryDirectory } from \"./rules/valid-repository-directory.js\";\nimport { rule as validVersion } from \"./rules/valid-version.js\";\n\nconst require = createRequire(import.meta.url || __filename);\n\nconst { name, version } = require(\"../package.json\") as {\n\tname: string;\n\tversion: string;\n};\n\nconst rules: Record<string, PackageJsonRuleModule> = {\n\t\"no-empty-fields\": noEmptyFields,\n\t\"no-redundant-files\": noRedundantFiles,\n\t\"order-properties\": orderProperties,\n\t...requireRules,\n\t\"repository-shorthand\": preferRepositoryShorthand,\n\t\"sort-collections\": sortCollections,\n\t\"unique-dependencies\": uniqueDependencies,\n\t\"valid-local-dependency\": validLocalDependency,\n\t\"valid-name\": validName,\n\t\"valid-package-definition\": validPackageDefinition,\n\t\"valid-repository-directory\": validRepositoryDirectory,\n\t\"valid-version\": validVersion,\n\n\t/** @deprecated use 'valid-package-definition' instead */\n\t\"valid-package-def\": {\n\t\t...validPackageDefinition,\n\t\tmeta: {\n\t\t\t...validPackageDefinition.meta,\n\t\t\tdeprecated: true,\n\t\t\tdocs: {\n\t\t\t\t...validPackageDefinition.meta.docs,\n\t\t\t\trecommended: false,\n\t\t\t},\n\t\t\treplacedBy: [\"valid-package-definition\"],\n\t\t},\n\t},\n};\n\nexport const plugin = {\n\tmeta: {\n\t\tname,\n\t\tversion,\n\t},\n\trules,\n};\n\nexport const recommendedRuleSettings = Object.fromEntries(\n\tObject.entries(rules)\n\t\t.filter(([, rule]) => rule.meta.docs?.recommended)\n\t\t.map(([name]) => [\"package-json/\" + name, \"error\" as const]),\n);\n"],"mappings":"AAAA,SAAS,qBAAqB;AAI9B,SAAS,QAAQ,qBAAqB;AACtC,SAAS,QAAQ,wBAAwB;AACzC,SAAS,QAAQ,uBAAuB;AACxC,SAAS,QAAQ,iCAAiC;AAClD,SAAS,SAAS,oBAAoB;AACtC,SAAS,QAAQ,uBAAuB;AACxC,SAAS,QAAQ,0BAA0B;AAC3C,SAAS,QAAQ,4BAA4B;AAC7C,SAAS,QAAQ,iBAAiB;AAClC,SAAS,QAAQ,8BAA8B;AAC/C,SAAS,QAAQ,gCAAgC;AACjD,SAAS,QAAQ,oBAAoB;AAErC,MAAMA,WAAU,cAAc,YAAY,OAAO,UAAU;AAE3D,MAAM,EAAE,MAAM,QAAQ,IAAIA,SAAQ,iBAAiB;AAKnD,MAAM,QAA+C;AAAA,EACpD,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,GAAG;AAAA,EACH,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,cAAc;AAAA,EACd,4BAA4B;AAAA,EAC5B,8BAA8B;AAAA,EAC9B,iBAAiB;AAAA;AAAA,EAGjB,qBAAqB;AAAA,IACpB,GAAG;AAAA,IACH,MAAM;AAAA,MACL,GAAG,uBAAuB;AAAA,MAC1B,YAAY;AAAA,MACZ,MAAM;AAAA,QACL,GAAG,uBAAuB,KAAK;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,YAAY,CAAC,0BAA0B;AAAA,IACxC;AAAA,EACD;AACD;AAEO,MAAM,SAAS;AAAA,EACrB,MAAM;AAAA,IACL;AAAA,IACA;AAAA,EACD;AAAA,EACA;AACD;AAEO,MAAM,0BAA0B,OAAO;AAAA,EAC7C,OAAO,QAAQ,KAAK,EAClB,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,KAAK,KAAK,MAAM,WAAW,EAChD,IAAI,CAAC,CAACC,KAAI,MAAM,CAAC,kBAAkBA,OAAM,OAAgB,CAAC;AAC7D;","names":["require","name"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var require_properties_exports = {};
|
|
20
|
+
__export(require_properties_exports, {
|
|
21
|
+
rules: () => rules
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(require_properties_exports);
|
|
24
|
+
var import_createRequirePropertyRule = require("../utils/createRequirePropertyRule.js");
|
|
25
|
+
const properties = [
|
|
26
|
+
["author", false],
|
|
27
|
+
["version", true]
|
|
28
|
+
// TODO: More to come!
|
|
29
|
+
];
|
|
30
|
+
const rules = properties.reduce(
|
|
31
|
+
(acc, [propertyName, isRecommended]) => {
|
|
32
|
+
acc[`require-${propertyName}`] = (0, import_createRequirePropertyRule.createRequirePropertyRule)(
|
|
33
|
+
propertyName,
|
|
34
|
+
isRecommended
|
|
35
|
+
);
|
|
36
|
+
return acc;
|
|
37
|
+
},
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
rules
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=require-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/rules/require-properties.ts"],"sourcesContent":["import type { PackageJsonRuleModule } from \"../createRule.js\";\n\nimport { createRequirePropertyRule } from \"../utils/createRequirePropertyRule.js\";\n\n// List of all properties we want to create require- rules for,\n// in the format [propertyName, isRecommended]\nconst properties = [\n\t[\"author\", false],\n\t[\"version\", true],\n\t// TODO: More to come!\n] satisfies [string, boolean][];\n\n/** All require- flavor rules */\nexport const rules = properties.reduce<Record<string, PackageJsonRuleModule>>(\n\t(acc, [propertyName, isRecommended]) => {\n\t\tacc[`require-${propertyName}`] = createRequirePropertyRule(\n\t\t\tpropertyName,\n\t\t\tisRecommended,\n\t\t);\n\t\treturn acc;\n\t},\n\t{},\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uCAA0C;AAI1C,MAAM,aAAa;AAAA,EAClB,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,WAAW,IAAI;AAAA;AAEjB;AAGO,MAAM,QAAQ,WAAW;AAAA,EAC/B,CAAC,KAAK,CAAC,cAAc,aAAa,MAAM;AACvC,QAAI,WAAW,YAAY,EAAE,QAAI;AAAA,MAChC;AAAA,MACA;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EACA,CAAC;AACF;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequirePropertyRule } from "../utils/createRequirePropertyRule.js";
|
|
2
|
+
const properties = [
|
|
3
|
+
["author", false],
|
|
4
|
+
["version", true]
|
|
5
|
+
// TODO: More to come!
|
|
6
|
+
];
|
|
7
|
+
const rules = properties.reduce(
|
|
8
|
+
(acc, [propertyName, isRecommended]) => {
|
|
9
|
+
acc[`require-${propertyName}`] = createRequirePropertyRule(
|
|
10
|
+
propertyName,
|
|
11
|
+
isRecommended
|
|
12
|
+
);
|
|
13
|
+
return acc;
|
|
14
|
+
},
|
|
15
|
+
{}
|
|
16
|
+
);
|
|
17
|
+
export {
|
|
18
|
+
rules
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=require-properties.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/rules/require-properties.ts"],"sourcesContent":["import type { PackageJsonRuleModule } from \"../createRule.js\";\n\nimport { createRequirePropertyRule } from \"../utils/createRequirePropertyRule.js\";\n\n// List of all properties we want to create require- rules for,\n// in the format [propertyName, isRecommended]\nconst properties = [\n\t[\"author\", false],\n\t[\"version\", true],\n\t// TODO: More to come!\n] satisfies [string, boolean][];\n\n/** All require- flavor rules */\nexport const rules = properties.reduce<Record<string, PackageJsonRuleModule>>(\n\t(acc, [propertyName, isRecommended]) => {\n\t\tacc[`require-${propertyName}`] = createRequirePropertyRule(\n\t\t\tpropertyName,\n\t\t\tisRecommended,\n\t\t);\n\t\treturn acc;\n\t},\n\t{},\n);\n"],"mappings":"AAEA,SAAS,iCAAiC;AAI1C,MAAM,aAAa;AAAA,EAClB,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,WAAW,IAAI;AAAA;AAEjB;AAGO,MAAM,QAAQ,WAAW;AAAA,EAC/B,CAAC,KAAK,CAAC,cAAc,aAAa,MAAM;AACvC,QAAI,WAAW,YAAY,EAAE,IAAI;AAAA,MAChC;AAAA,MACA;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAAA,EACA,CAAC;AACF;","names":[]}
|
|
@@ -44,8 +44,8 @@ const rule = (0, import_createRule.createRule)({
|
|
|
44
44
|
Object.entries(peerDependencies ?? {}),
|
|
45
45
|
Object.entries(devDependencies ?? {})
|
|
46
46
|
];
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
for (const obj of depObjs) {
|
|
48
|
+
for (const [key, value] of obj) {
|
|
49
49
|
const response = (localPath) => {
|
|
50
50
|
const filePath = import_path.default.join(
|
|
51
51
|
context.filename.replace(/package\.json/g, "/"),
|
|
@@ -53,16 +53,7 @@ const rule = (0, import_createRule.createRule)({
|
|
|
53
53
|
"/package.json"
|
|
54
54
|
);
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
context.report({
|
|
58
|
-
data: {
|
|
59
|
-
package: key,
|
|
60
|
-
path: value
|
|
61
|
-
},
|
|
62
|
-
messageId: "invalidPath",
|
|
63
|
-
node: context.sourceCode.ast
|
|
64
|
-
});
|
|
65
|
-
}
|
|
56
|
+
require.resolve(filePath);
|
|
66
57
|
} catch {
|
|
67
58
|
context.report({
|
|
68
59
|
data: {
|
|
@@ -80,8 +71,8 @@ const rule = (0, import_createRule.createRule)({
|
|
|
80
71
|
if (value.startsWith("file:")) {
|
|
81
72
|
response("file:");
|
|
82
73
|
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
85
76
|
}
|
|
86
77
|
};
|
|
87
78
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/valid-local-dependency.ts"],"sourcesContent":["import path from \"path\";\n\nimport { createRule } from \"../createRule.js\";\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst original = JSON.parse(context.sourceCode.text) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tconst { dependencies, devDependencies, peerDependencies } =\n\t\t\t\t\toriginal;\n\n\t\t\t\tconst depObjs = [\n\t\t\t\t\tObject.entries(dependencies ?? {}),\n\t\t\t\t\tObject.entries(peerDependencies ?? {}),\n\t\t\t\t\tObject.entries(devDependencies ?? {}),\n\t\t\t\t] as [string, string][][];\n\n\t\t\t\
|
|
1
|
+
{"version":3,"sources":["../../src/rules/valid-local-dependency.ts"],"sourcesContent":["import path from \"path\";\n\nimport { createRule } from \"../createRule.js\";\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst original = JSON.parse(context.sourceCode.text) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tconst { dependencies, devDependencies, peerDependencies } =\n\t\t\t\t\toriginal;\n\n\t\t\t\tconst depObjs = [\n\t\t\t\t\tObject.entries(dependencies ?? {}),\n\t\t\t\t\tObject.entries(peerDependencies ?? {}),\n\t\t\t\t\tObject.entries(devDependencies ?? {}),\n\t\t\t\t] as [string, string][][];\n\n\t\t\t\tfor (const obj of depObjs) {\n\t\t\t\t\tfor (const [key, value] of obj) {\n\t\t\t\t\t\tconst response = (localPath: RegExp | string) => {\n\t\t\t\t\t\t\tconst filePath = path.join(\n\t\t\t\t\t\t\t\tcontext.filename.replace(/package\\.json/g, \"/\"),\n\t\t\t\t\t\t\t\tvalue.replace(new RegExp(localPath, \"g\"), \"\"),\n\t\t\t\t\t\t\t\t\"/package.json\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Attempt to resolve the file path, and if it fails\n\t\t\t\t\t\t\t// and throws, then we know it's invalid.\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trequire.resolve(filePath);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\tpackage: key,\n\t\t\t\t\t\t\t\t\t\tpath: value,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tmessageId: \"invalidPath\",\n\t\t\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (value.startsWith(\"link:\")) {\n\t\t\t\t\t\t\tresponse(\"link:\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (value.startsWith(\"file:\")) {\n\t\t\t\t\t\t\tresponse(\"file:\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n\n\tmeta: {\n\t\tdocs: {\n\t\t\tcategory: \"Best Practices\",\n\t\t\tdescription:\n\t\t\t\t\"Checks existence of local dependencies in the package.json\",\n\t\t\trecommended: true,\n\t\t},\n\t\tmessages: {\n\t\t\tinvalidPath:\n\t\t\t\t\"The package {{package}} does not exist given the specified path: {{path}}.\",\n\t\t},\n\t\tschema: [],\n\t\ttype: \"problem\",\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,wBAA2B;AAEpB,MAAM,WAAO,8BAAW;AAAA,EAC9B,OAAO,SAAS;AACf,WAAO;AAAA,MACN,iBAAiB;AAChB,cAAM,WAAW,KAAK,MAAM,QAAQ,WAAW,IAAI;AAInD,cAAM,EAAE,cAAc,iBAAiB,iBAAiB,IACvD;AAED,cAAM,UAAU;AAAA,UACf,OAAO,QAAQ,gBAAgB,CAAC,CAAC;AAAA,UACjC,OAAO,QAAQ,oBAAoB,CAAC,CAAC;AAAA,UACrC,OAAO,QAAQ,mBAAmB,CAAC,CAAC;AAAA,QACrC;AAEA,mBAAW,OAAO,SAAS;AAC1B,qBAAW,CAAC,KAAK,KAAK,KAAK,KAAK;AAC/B,kBAAM,WAAW,CAAC,cAA+B;AAChD,oBAAM,WAAW,YAAAA,QAAK;AAAA,gBACrB,QAAQ,SAAS,QAAQ,kBAAkB,GAAG;AAAA,gBAC9C,MAAM,QAAQ,IAAI,OAAO,WAAW,GAAG,GAAG,EAAE;AAAA,gBAC5C;AAAA,cACD;AAIA,kBAAI;AACH,wBAAQ,QAAQ,QAAQ;AAAA,cACzB,QAAQ;AACP,wBAAQ,OAAO;AAAA,kBACd,MAAM;AAAA,oBACL,SAAS;AAAA,oBACT,MAAM;AAAA,kBACP;AAAA,kBACA,WAAW;AAAA,kBACX,MAAM,QAAQ,WAAW;AAAA,gBAC1B,CAAC;AAAA,cACF;AAAA,YACD;AAEA,gBAAI,MAAM,WAAW,OAAO,GAAG;AAC9B,uBAAS,OAAO;AAAA,YACjB;AAEA,gBAAI,MAAM,WAAW,OAAO,GAAG;AAC9B,uBAAS,OAAO;AAAA,YACjB;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM;AAAA,IACL,MAAM;AAAA,MACL,UAAU;AAAA,MACV,aACC;AAAA,MACD,aAAa;AAAA,IACd;AAAA,IACA,UAAU;AAAA,MACT,aACC;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACP;AACD,CAAC;","names":["path"]}
|
|
@@ -11,8 +11,8 @@ const rule = createRule({
|
|
|
11
11
|
Object.entries(peerDependencies ?? {}),
|
|
12
12
|
Object.entries(devDependencies ?? {})
|
|
13
13
|
];
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
for (const obj of depObjs) {
|
|
15
|
+
for (const [key, value] of obj) {
|
|
16
16
|
const response = (localPath) => {
|
|
17
17
|
const filePath = path.join(
|
|
18
18
|
context.filename.replace(/package\.json/g, "/"),
|
|
@@ -20,16 +20,7 @@ const rule = createRule({
|
|
|
20
20
|
"/package.json"
|
|
21
21
|
);
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
context.report({
|
|
25
|
-
data: {
|
|
26
|
-
package: key,
|
|
27
|
-
path: value
|
|
28
|
-
},
|
|
29
|
-
messageId: "invalidPath",
|
|
30
|
-
node: context.sourceCode.ast
|
|
31
|
-
});
|
|
32
|
-
}
|
|
23
|
+
require.resolve(filePath);
|
|
33
24
|
} catch {
|
|
34
25
|
context.report({
|
|
35
26
|
data: {
|
|
@@ -47,8 +38,8 @@ const rule = createRule({
|
|
|
47
38
|
if (value.startsWith("file:")) {
|
|
48
39
|
response("file:");
|
|
49
40
|
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
52
43
|
}
|
|
53
44
|
};
|
|
54
45
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/valid-local-dependency.ts"],"sourcesContent":["import path from \"path\";\n\nimport { createRule } from \"../createRule.js\";\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst original = JSON.parse(context.sourceCode.text) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tconst { dependencies, devDependencies, peerDependencies } =\n\t\t\t\t\toriginal;\n\n\t\t\t\tconst depObjs = [\n\t\t\t\t\tObject.entries(dependencies ?? {}),\n\t\t\t\t\tObject.entries(peerDependencies ?? {}),\n\t\t\t\t\tObject.entries(devDependencies ?? {}),\n\t\t\t\t] as [string, string][][];\n\n\t\t\t\
|
|
1
|
+
{"version":3,"sources":["../../src/rules/valid-local-dependency.ts"],"sourcesContent":["import path from \"path\";\n\nimport { createRule } from \"../createRule.js\";\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst original = JSON.parse(context.sourceCode.text) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\tconst { dependencies, devDependencies, peerDependencies } =\n\t\t\t\t\toriginal;\n\n\t\t\t\tconst depObjs = [\n\t\t\t\t\tObject.entries(dependencies ?? {}),\n\t\t\t\t\tObject.entries(peerDependencies ?? {}),\n\t\t\t\t\tObject.entries(devDependencies ?? {}),\n\t\t\t\t] as [string, string][][];\n\n\t\t\t\tfor (const obj of depObjs) {\n\t\t\t\t\tfor (const [key, value] of obj) {\n\t\t\t\t\t\tconst response = (localPath: RegExp | string) => {\n\t\t\t\t\t\t\tconst filePath = path.join(\n\t\t\t\t\t\t\t\tcontext.filename.replace(/package\\.json/g, \"/\"),\n\t\t\t\t\t\t\t\tvalue.replace(new RegExp(localPath, \"g\"), \"\"),\n\t\t\t\t\t\t\t\t\"/package.json\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// Attempt to resolve the file path, and if it fails\n\t\t\t\t\t\t\t// and throws, then we know it's invalid.\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\trequire.resolve(filePath);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\tpackage: key,\n\t\t\t\t\t\t\t\t\t\tpath: value,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tmessageId: \"invalidPath\",\n\t\t\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (value.startsWith(\"link:\")) {\n\t\t\t\t\t\t\tresponse(\"link:\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (value.startsWith(\"file:\")) {\n\t\t\t\t\t\t\tresponse(\"file:\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t},\n\n\tmeta: {\n\t\tdocs: {\n\t\t\tcategory: \"Best Practices\",\n\t\t\tdescription:\n\t\t\t\t\"Checks existence of local dependencies in the package.json\",\n\t\t\trecommended: true,\n\t\t},\n\t\tmessages: {\n\t\t\tinvalidPath:\n\t\t\t\t\"The package {{package}} does not exist given the specified path: {{path}}.\",\n\t\t},\n\t\tschema: [],\n\t\ttype: \"problem\",\n\t},\n});\n"],"mappings":"AAAA,OAAO,UAAU;AAEjB,SAAS,kBAAkB;AAEpB,MAAM,OAAO,WAAW;AAAA,EAC9B,OAAO,SAAS;AACf,WAAO;AAAA,MACN,iBAAiB;AAChB,cAAM,WAAW,KAAK,MAAM,QAAQ,WAAW,IAAI;AAInD,cAAM,EAAE,cAAc,iBAAiB,iBAAiB,IACvD;AAED,cAAM,UAAU;AAAA,UACf,OAAO,QAAQ,gBAAgB,CAAC,CAAC;AAAA,UACjC,OAAO,QAAQ,oBAAoB,CAAC,CAAC;AAAA,UACrC,OAAO,QAAQ,mBAAmB,CAAC,CAAC;AAAA,QACrC;AAEA,mBAAW,OAAO,SAAS;AAC1B,qBAAW,CAAC,KAAK,KAAK,KAAK,KAAK;AAC/B,kBAAM,WAAW,CAAC,cAA+B;AAChD,oBAAM,WAAW,KAAK;AAAA,gBACrB,QAAQ,SAAS,QAAQ,kBAAkB,GAAG;AAAA,gBAC9C,MAAM,QAAQ,IAAI,OAAO,WAAW,GAAG,GAAG,EAAE;AAAA,gBAC5C;AAAA,cACD;AAIA,kBAAI;AACH,wBAAQ,QAAQ,QAAQ;AAAA,cACzB,QAAQ;AACP,wBAAQ,OAAO;AAAA,kBACd,MAAM;AAAA,oBACL,SAAS;AAAA,oBACT,MAAM;AAAA,kBACP;AAAA,kBACA,WAAW;AAAA,kBACX,MAAM,QAAQ,WAAW;AAAA,gBAC1B,CAAC;AAAA,cACF;AAAA,YACD;AAEA,gBAAI,MAAM,WAAW,OAAO,GAAG;AAC9B,uBAAS,OAAO;AAAA,YACjB;AAEA,gBAAI,MAAM,WAAW,OAAO,GAAG;AAC9B,uBAAS,OAAO;AAAA,YACjB;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM;AAAA,IACL,MAAM;AAAA,MACL,UAAU;AAAA,MACV,aACC;AAAA,MACD,aAAa;AAAA,IACd;AAAA,IACA,UAAU;AAAA,MACT,aACC;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACP;AACD,CAAC;","names":[]}
|
|
@@ -33,9 +33,7 @@ const rule = (0, import_createRule.createRule)({
|
|
|
33
33
|
create(context) {
|
|
34
34
|
return {
|
|
35
35
|
"Program:exit"() {
|
|
36
|
-
const validation = import_package_json_validator.
|
|
37
|
-
context.sourceCode.text
|
|
38
|
-
);
|
|
36
|
+
const validation = (0, import_package_json_validator.validate)(context.sourceCode.text);
|
|
39
37
|
validation.errors?.filter(isUsableError).forEach((message) => {
|
|
40
38
|
if (message) {
|
|
41
39
|
context.report({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/valid-package-definition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/rules/valid-package-definition.ts"],"sourcesContent":["import { validate } from \"package-json-validator\";\n\nimport { createRule } from \"../createRule.js\";\n\n// package-json-validator does not correctly recognize shorthand for repositories and alternate dependency statements, so we discard those values.\n// it also enforces a stricter code for npm than is really appropriate,\n// so we disable some other errors here.\nconst unusedErrorPatterns = [\n\t/^Url not valid/i,\n\t/^Invalid version range for .+?: (?:file|npm|workspace):/i,\n\t/^author field should have name/i,\n];\n\nconst isUsableError = (errorText: string) =>\n\tunusedErrorPatterns.every((pattern) => !pattern.test(errorText));\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst validation = validate(context.sourceCode.text);\n\n\t\t\t\tvalidation.errors?.filter(isUsableError).forEach((message) => {\n\t\t\t\t\tif (message) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\t// eslint-disable-next-line eslint-plugin/prefer-message-ids\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n\n\t// eslint-disable-next-line eslint-plugin/prefer-message-ids\n\tmeta: {\n\t\tdocs: {\n\t\t\tcategory: \"Best Practices\",\n\t\t\tdescription:\n\t\t\t\t\"Enforce that package.json has all properties required by the npm spec\",\n\t\t\trecommended: true,\n\t\t},\n\t\tschema: [],\n\t\ttype: \"problem\",\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAyB;AAEzB,wBAA2B;AAK3B,MAAM,sBAAsB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACD;AAEA,MAAM,gBAAgB,CAAC,cACtB,oBAAoB,MAAM,CAAC,YAAY,CAAC,QAAQ,KAAK,SAAS,CAAC;AAEzD,MAAM,WAAO,8BAAW;AAAA,EAC9B,OAAO,SAAS;AACf,WAAO;AAAA,MACN,iBAAiB;AAChB,cAAM,iBAAa,wCAAS,QAAQ,WAAW,IAAI;AAEnD,mBAAW,QAAQ,OAAO,aAAa,EAAE,QAAQ,CAAC,YAAY;AAC7D,cAAI,SAAS;AACZ,oBAAQ,OAAO;AAAA;AAAA,cAEd;AAAA,cACA,MAAM,QAAQ,WAAW;AAAA,YAC1B,CAAC;AAAA,UACF;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AAAA;AAAA,EAGA,MAAM;AAAA,IACL,MAAM;AAAA,MACL,UAAU;AAAA,MACV,aACC;AAAA,MACD,aAAa;AAAA,IACd;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACP;AACD,CAAC;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { validate } from "package-json-validator";
|
|
2
2
|
import { createRule } from "../createRule.js";
|
|
3
3
|
const unusedErrorPatterns = [
|
|
4
4
|
/^Url not valid/i,
|
|
@@ -10,9 +10,7 @@ const rule = createRule({
|
|
|
10
10
|
create(context) {
|
|
11
11
|
return {
|
|
12
12
|
"Program:exit"() {
|
|
13
|
-
const validation =
|
|
14
|
-
context.sourceCode.text
|
|
15
|
-
);
|
|
13
|
+
const validation = validate(context.sourceCode.text);
|
|
16
14
|
validation.errors?.filter(isUsableError).forEach((message) => {
|
|
17
15
|
if (message) {
|
|
18
16
|
context.report({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/valid-package-definition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/rules/valid-package-definition.ts"],"sourcesContent":["import { validate } from \"package-json-validator\";\n\nimport { createRule } from \"../createRule.js\";\n\n// package-json-validator does not correctly recognize shorthand for repositories and alternate dependency statements, so we discard those values.\n// it also enforces a stricter code for npm than is really appropriate,\n// so we disable some other errors here.\nconst unusedErrorPatterns = [\n\t/^Url not valid/i,\n\t/^Invalid version range for .+?: (?:file|npm|workspace):/i,\n\t/^author field should have name/i,\n];\n\nconst isUsableError = (errorText: string) =>\n\tunusedErrorPatterns.every((pattern) => !pattern.test(errorText));\n\nexport const rule = createRule({\n\tcreate(context) {\n\t\treturn {\n\t\t\t\"Program:exit\"() {\n\t\t\t\tconst validation = validate(context.sourceCode.text);\n\n\t\t\t\tvalidation.errors?.filter(isUsableError).forEach((message) => {\n\t\t\t\t\tif (message) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\t// eslint-disable-next-line eslint-plugin/prefer-message-ids\n\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n\n\t// eslint-disable-next-line eslint-plugin/prefer-message-ids\n\tmeta: {\n\t\tdocs: {\n\t\t\tcategory: \"Best Practices\",\n\t\t\tdescription:\n\t\t\t\t\"Enforce that package.json has all properties required by the npm spec\",\n\t\t\trecommended: true,\n\t\t},\n\t\tschema: [],\n\t\ttype: \"problem\",\n\t},\n});\n"],"mappings":"AAAA,SAAS,gBAAgB;AAEzB,SAAS,kBAAkB;AAK3B,MAAM,sBAAsB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACD;AAEA,MAAM,gBAAgB,CAAC,cACtB,oBAAoB,MAAM,CAAC,YAAY,CAAC,QAAQ,KAAK,SAAS,CAAC;AAEzD,MAAM,OAAO,WAAW;AAAA,EAC9B,OAAO,SAAS;AACf,WAAO;AAAA,MACN,iBAAiB;AAChB,cAAM,aAAa,SAAS,QAAQ,WAAW,IAAI;AAEnD,mBAAW,QAAQ,OAAO,aAAa,EAAE,QAAQ,CAAC,YAAY;AAC7D,cAAI,SAAS;AACZ,oBAAQ,OAAO;AAAA;AAAA,cAEd;AAAA,cACA,MAAM,QAAQ,WAAW;AAAA,YAC1B,CAAC;AAAA,UACF;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD;AAAA;AAAA,EAGA,MAAM;AAAA,IACL,MAAM;AAAA,MACL,UAAU;AAAA,MACV,aACC;AAAA,MACD,aAAa;AAAA,IACd;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACP;AACD,CAAC;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import * as jsonc_eslint_parser from 'jsonc-eslint-parser';
|
|
3
|
+
import { PackageJsonRuleContext } from '../createRule.mjs';
|
|
4
|
+
import 'estree';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a top-level property name, create a rule that requires that property to be present.
|
|
8
|
+
* Optionally, include it in the recommended config.
|
|
9
|
+
*/
|
|
10
|
+
declare const createRequirePropertyRule: (propertyName: string, isRecommended?: boolean) => {
|
|
11
|
+
create(context: PackageJsonRuleContext<unknown[]>): jsonc_eslint_parser.RuleListener;
|
|
12
|
+
meta: eslint.Rule.RuleMetaData;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { createRequirePropertyRule };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import * as jsonc_eslint_parser from 'jsonc-eslint-parser';
|
|
3
|
+
import { PackageJsonRuleContext } from '../createRule.js';
|
|
4
|
+
import 'estree';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a top-level property name, create a rule that requires that property to be present.
|
|
8
|
+
* Optionally, include it in the recommended config.
|
|
9
|
+
*/
|
|
10
|
+
declare const createRequirePropertyRule: (propertyName: string, isRecommended?: boolean) => {
|
|
11
|
+
create(context: PackageJsonRuleContext<unknown[]>): jsonc_eslint_parser.RuleListener;
|
|
12
|
+
meta: eslint.Rule.RuleMetaData;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { createRequirePropertyRule };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createRequirePropertyRule_exports = {};
|
|
20
|
+
__export(createRequirePropertyRule_exports, {
|
|
21
|
+
createRequirePropertyRule: () => createRequirePropertyRule
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(createRequirePropertyRule_exports);
|
|
24
|
+
var import_createRule = require("../createRule.js");
|
|
25
|
+
var import_predicates = require("./predicates.js");
|
|
26
|
+
const createRequirePropertyRule = (propertyName, isRecommended = false) => {
|
|
27
|
+
return (0, import_createRule.createRule)({
|
|
28
|
+
create(context) {
|
|
29
|
+
return {
|
|
30
|
+
"Program > JSONExpressionStatement > JSONObjectExpression"(node) {
|
|
31
|
+
if (!node.properties.some(
|
|
32
|
+
(property) => (0, import_predicates.isJSONStringLiteral)(property.key) && property.key.value === propertyName
|
|
33
|
+
)) {
|
|
34
|
+
context.report({
|
|
35
|
+
data: { property: propertyName },
|
|
36
|
+
messageId: "missing",
|
|
37
|
+
node: context.sourceCode.ast
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
meta: {
|
|
44
|
+
docs: {
|
|
45
|
+
description: `Requires the \`${propertyName}\` property to be present.`,
|
|
46
|
+
recommended: isRecommended
|
|
47
|
+
},
|
|
48
|
+
messages: {
|
|
49
|
+
missing: "Property '{{property}}' is required."
|
|
50
|
+
},
|
|
51
|
+
schema: [],
|
|
52
|
+
type: "suggestion"
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
createRequirePropertyRule
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=createRequirePropertyRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/createRequirePropertyRule.ts"],"sourcesContent":["import type { AST as JsonAST } from \"jsonc-eslint-parser\";\n\nimport { createRule } from \"../createRule.js\";\nimport { isJSONStringLiteral } from \"./predicates.js\";\n\n/**\n * Given a top-level property name, create a rule that requires that property to be present.\n * Optionally, include it in the recommended config.\n */\nexport const createRequirePropertyRule = (\n\tpropertyName: string,\n\tisRecommended = false,\n) => {\n\treturn createRule({\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\t\"Program > JSONExpressionStatement > JSONObjectExpression\"(\n\t\t\t\t\tnode: JsonAST.JSONObjectExpression,\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!node.properties.some(\n\t\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\t\tisJSONStringLiteral(property.key) &&\n\t\t\t\t\t\t\t\tproperty.key.value === propertyName,\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tdata: { property: propertyName },\n\t\t\t\t\t\t\tmessageId: \"missing\",\n\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tmeta: {\n\t\t\tdocs: {\n\t\t\t\tdescription: `Requires the \\`${propertyName}\\` property to be present.`,\n\t\t\t\trecommended: isRecommended,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\tmissing: \"Property '{{property}}' is required.\",\n\t\t\t},\n\t\t\tschema: [],\n\t\t\ttype: \"suggestion\",\n\t\t},\n\t});\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA2B;AAC3B,wBAAoC;AAM7B,MAAM,4BAA4B,CACxC,cACA,gBAAgB,UACZ;AACJ,aAAO,8BAAW;AAAA,IACjB,OAAO,SAAS;AACf,aAAO;AAAA,QACN,2DACC,MACC;AACD,cACC,CAAC,KAAK,WAAW;AAAA,YAChB,CAAC,iBACA,uCAAoB,SAAS,GAAG,KAChC,SAAS,IAAI,UAAU;AAAA,UACzB,GACC;AACD,oBAAQ,OAAO;AAAA,cACd,MAAM,EAAE,UAAU,aAAa;AAAA,cAC/B,WAAW;AAAA,cACX,MAAM,QAAQ,WAAW;AAAA,YAC1B,CAAC;AAAA,UACF;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,MAAM;AAAA,MACL,MAAM;AAAA,QACL,aAAa,kBAAkB,YAAY;AAAA,QAC3C,aAAa;AAAA,MACd;AAAA,MACA,UAAU;AAAA,QACT,SAAS;AAAA,MACV;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,MAAM;AAAA,IACP;AAAA,EACD,CAAC;AACF;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRule } from "../createRule.js";
|
|
2
|
+
import { isJSONStringLiteral } from "./predicates.js";
|
|
3
|
+
const createRequirePropertyRule = (propertyName, isRecommended = false) => {
|
|
4
|
+
return createRule({
|
|
5
|
+
create(context) {
|
|
6
|
+
return {
|
|
7
|
+
"Program > JSONExpressionStatement > JSONObjectExpression"(node) {
|
|
8
|
+
if (!node.properties.some(
|
|
9
|
+
(property) => isJSONStringLiteral(property.key) && property.key.value === propertyName
|
|
10
|
+
)) {
|
|
11
|
+
context.report({
|
|
12
|
+
data: { property: propertyName },
|
|
13
|
+
messageId: "missing",
|
|
14
|
+
node: context.sourceCode.ast
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
meta: {
|
|
21
|
+
docs: {
|
|
22
|
+
description: `Requires the \`${propertyName}\` property to be present.`,
|
|
23
|
+
recommended: isRecommended
|
|
24
|
+
},
|
|
25
|
+
messages: {
|
|
26
|
+
missing: "Property '{{property}}' is required."
|
|
27
|
+
},
|
|
28
|
+
schema: [],
|
|
29
|
+
type: "suggestion"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
createRequirePropertyRule
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=createRequirePropertyRule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/createRequirePropertyRule.ts"],"sourcesContent":["import type { AST as JsonAST } from \"jsonc-eslint-parser\";\n\nimport { createRule } from \"../createRule.js\";\nimport { isJSONStringLiteral } from \"./predicates.js\";\n\n/**\n * Given a top-level property name, create a rule that requires that property to be present.\n * Optionally, include it in the recommended config.\n */\nexport const createRequirePropertyRule = (\n\tpropertyName: string,\n\tisRecommended = false,\n) => {\n\treturn createRule({\n\t\tcreate(context) {\n\t\t\treturn {\n\t\t\t\t\"Program > JSONExpressionStatement > JSONObjectExpression\"(\n\t\t\t\t\tnode: JsonAST.JSONObjectExpression,\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!node.properties.some(\n\t\t\t\t\t\t\t(property) =>\n\t\t\t\t\t\t\t\tisJSONStringLiteral(property.key) &&\n\t\t\t\t\t\t\t\tproperty.key.value === propertyName,\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tdata: { property: propertyName },\n\t\t\t\t\t\t\tmessageId: \"missing\",\n\t\t\t\t\t\t\tnode: context.sourceCode.ast,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tmeta: {\n\t\t\tdocs: {\n\t\t\t\tdescription: `Requires the \\`${propertyName}\\` property to be present.`,\n\t\t\t\trecommended: isRecommended,\n\t\t\t},\n\t\t\tmessages: {\n\t\t\t\tmissing: \"Property '{{property}}' is required.\",\n\t\t\t},\n\t\t\tschema: [],\n\t\t\ttype: \"suggestion\",\n\t\t},\n\t});\n};\n"],"mappings":"AAEA,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAM7B,MAAM,4BAA4B,CACxC,cACA,gBAAgB,UACZ;AACJ,SAAO,WAAW;AAAA,IACjB,OAAO,SAAS;AACf,aAAO;AAAA,QACN,2DACC,MACC;AACD,cACC,CAAC,KAAK,WAAW;AAAA,YAChB,CAAC,aACA,oBAAoB,SAAS,GAAG,KAChC,SAAS,IAAI,UAAU;AAAA,UACzB,GACC;AACD,oBAAQ,OAAO;AAAA,cACd,MAAM,EAAE,UAAU,aAAa;AAAA,cAC/B,WAAW;AAAA,cACX,MAAM,QAAQ,WAAW;AAAA,YAC1B,CAAC;AAAA,UACF;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,MAAM;AAAA,MACL,MAAM;AAAA,QACL,aAAa,kBAAkB,YAAY;AAAA,QAC3C,aAAa;AAAA,MACd;AAAA,MACA,UAAU;AAAA,QACT,SAAS;AAAA,MACV;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,MAAM;AAAA,IACP;AAAA,EACD,CAAC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-package-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Rules for consistent, readable, and valid package.json files. 🗂️",
|
|
5
5
|
"homepage": "https://github.com/JoshuaKGoldberg/eslint-plugin-package-json#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -33,16 +33,13 @@
|
|
|
33
33
|
},
|
|
34
34
|
"main": "./lib/index.js",
|
|
35
35
|
"files": [
|
|
36
|
-
"lib
|
|
37
|
-
"package.json",
|
|
38
|
-
"LICENSE.md",
|
|
39
|
-
"README.md"
|
|
36
|
+
"lib"
|
|
40
37
|
],
|
|
41
38
|
"scripts": {
|
|
42
39
|
"build": "tsup",
|
|
43
40
|
"format": "prettier \"**/*\" --ignore-unknown",
|
|
44
41
|
"lint": "eslint . --max-warnings 0",
|
|
45
|
-
"lint:eslint-docs": "
|
|
42
|
+
"lint:eslint-docs": "pnpm update:eslint-docs --check",
|
|
46
43
|
"lint:knip": "knip",
|
|
47
44
|
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\"",
|
|
48
45
|
"lint:packages": "pnpm dedupe --check",
|
|
@@ -61,7 +58,7 @@
|
|
|
61
58
|
"detect-indent": "6.1.0",
|
|
62
59
|
"detect-newline": "3.1.0",
|
|
63
60
|
"eslint-fix-utils": "^0.2.0",
|
|
64
|
-
"package-json-validator": "^0.
|
|
61
|
+
"package-json-validator": "^0.10.0",
|
|
65
62
|
"semver": "^7.5.4",
|
|
66
63
|
"sort-object-keys": "^1.1.3",
|
|
67
64
|
"sort-package-json": "^2.12.0",
|
|
@@ -95,7 +92,7 @@
|
|
|
95
92
|
"knip": "^5.0.0",
|
|
96
93
|
"lint-staged": "^15.3.0",
|
|
97
94
|
"markdownlint": "^0.37.4",
|
|
98
|
-
"markdownlint-cli": "^0.
|
|
95
|
+
"markdownlint-cli": "^0.44.0",
|
|
99
96
|
"prettier": "^3.2.4",
|
|
100
97
|
"prettier-plugin-curly": "^0.3.0",
|
|
101
98
|
"prettier-plugin-packagejson": "^2.4.9",
|
|
@@ -110,7 +107,7 @@
|
|
|
110
107
|
"eslint": ">=8.0.0",
|
|
111
108
|
"jsonc-eslint-parser": "^2.0.0"
|
|
112
109
|
},
|
|
113
|
-
"packageManager": "pnpm@
|
|
110
|
+
"packageManager": "pnpm@10.1.0",
|
|
114
111
|
"engines": {
|
|
115
112
|
"node": ">=18"
|
|
116
113
|
},
|