@zukhruf/eslint 0.3.53 → 0.3.54

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 CHANGED
@@ -188,6 +188,8 @@ export default defineConfig({
188
188
 
189
189
  The rule decides each manifest's options itself, so your options add to the shared policy and never replace it. `projects` keys are folders relative to the workspace root. Like Nx's own rule, it needs the project graph that `nx` caches; without it, the rule checks nothing. It needs `@nx/devkit`, which `@nx/eslint-plugin` installs.
190
190
 
191
+ `manifest/recommended` also has `manifest/no-truncated-description`. The npm registry keeps only the first 255 characters of a package's `description`. `npm view` and the npm search do not show the rest. The rule reports a `description` that is longer than 255 characters. It does not check a manifest with `"private": true`, because npm does not publish it. Put the key fact in the description, and put the details in the README.
192
+
191
193
  ## React Native: Hermes
192
194
 
193
195
  `@zukhruf/eslint/react-native` needs `eslint-plugin-es-x`. es-x 10 needs ESLint 10.6 or later; on ESLint 9, install `eslint-plugin-es-x@9`. `hermes/recommended` checks the code that ships in the app, and leaves tests, config files and scripts alone, because those run in Node:
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ /**
3
+ * The npm registry cuts a package's `description` to 255 characters, so the
4
+ * rest never shows in `npm view` or in a search. npm does not publish a
5
+ * manifest with `"private": true`, so the rule does not check it.
6
+ */
7
+ declare const rule: Rule.RuleModule;
8
+ export default rule;
9
+ //# sourceMappingURL=no-truncated-description.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-truncated-description.d.ts","sourceRoot":"","sources":["../../src/manifest/no-truncated-description.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAwBnC;;;;GAIG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAiChB,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { isType } from "../authoring/ast.js";
2
+ /** The npm registry stores at most this many characters of a description. */
3
+ const LIMIT = 255;
4
+ /**
5
+ * The value of the manifest's top-level `name` field. npm reads package.json
6
+ * with `JSON.parse`, so every key is a quoted string.
7
+ */
8
+ function fieldValue(manifest, name) {
9
+ const properties = manifest['properties'];
10
+ const property = Array.isArray(properties)
11
+ ? properties.find((entry) => isType(entry, 'JSONProperty') &&
12
+ isType(entry['key'], 'JSONLiteral') &&
13
+ entry['key']['value'] === name)
14
+ : undefined;
15
+ return isType(property, 'JSONProperty') ? property['value'] : undefined;
16
+ }
17
+ /**
18
+ * The npm registry cuts a package's `description` to 255 characters, so the
19
+ * rest never shows in `npm view` or in a search. npm does not publish a
20
+ * manifest with `"private": true`, so the rule does not check it.
21
+ */
22
+ const rule = {
23
+ meta: {
24
+ type: 'problem',
25
+ docs: {
26
+ description: 'Disallow a description that the npm registry cuts, in a package.json that npm can publish',
27
+ },
28
+ schema: [],
29
+ messages: {
30
+ truncated: 'The description has {{length}} characters. The npm registry stores at most {{limit}}, so it cuts the rest. Keep the key fact here and move the detail to the README.',
31
+ },
32
+ },
33
+ create(context) {
34
+ return {
35
+ 'JSONExpressionStatement > JSONObjectExpression'(manifest) {
36
+ if (!isType(manifest, 'JSONObjectExpression'))
37
+ return;
38
+ const isPrivate = fieldValue(manifest, 'private');
39
+ if (isType(isPrivate, 'JSONLiteral') && isPrivate['value'] === true) {
40
+ return;
41
+ }
42
+ const description = fieldValue(manifest, 'description');
43
+ if (!isType(description, 'JSONLiteral'))
44
+ return;
45
+ const text = description['value'];
46
+ if (typeof text !== 'string' || text.length <= LIMIT)
47
+ return;
48
+ context.report({
49
+ node: description,
50
+ messageId: 'truncated',
51
+ data: { length: String(text.length), limit: String(LIMIT) },
52
+ });
53
+ },
54
+ };
55
+ },
56
+ };
57
+ export default rule;
58
+ //# sourceMappingURL=no-truncated-description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-truncated-description.js","sourceRoot":"","sources":["../../src/manifest/no-truncated-description.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,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QAAQ,EAAE,aAAa,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC;oBAAE,OAAO;gBAChD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;gBAClC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;oBAAE,OAAO;gBAC7D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,WAAW;oBACtB,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;iBAC5D,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -4,7 +4,8 @@ import type { Linter } from 'eslint';
4
4
  * shipped code needs. How many depends on the project's shape: a bundled app
5
5
  * declares the whole closure its workspace imports pull in, an unbundled
6
6
  * project only its own imports. Islands are checked by
7
- * `island/dependency-checks`.
7
+ * `island/dependency-checks`. A manifest that npm can publish keeps its
8
+ * description inside what the npm registry stores.
8
9
  */
9
10
  declare const plugin: {
10
11
  meta: {
@@ -13,6 +14,7 @@ declare const plugin: {
13
14
  };
14
15
  rules: {
15
16
  'dependency-checks': import("eslint").Rule.RuleModule;
17
+ 'no-truncated-description': import("eslint").Rule.RuleModule;
16
18
  };
17
19
  configs: Record<string, Linter.Config<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[]>;
18
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/manifest/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQ7C;;;;;;GAMG;AACH,QAAA,MAAM,MAAM;;;;;;;;;CAIa,CAAC;AAY1B,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/manifest/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAS7C;;;;;;;GAOG;AACH,QAAA,MAAM,MAAM;;;;;;;;;;CAOa,CAAC;AAe1B,eAAe,MAAM,CAAC"}
@@ -1,17 +1,22 @@
1
1
  import * as jsonc from 'jsonc-eslint-parser';
2
2
  import { PACKAGE_JSON } from "../files.js";
3
3
  import dependencyChecks from "./dependency-checks.js";
4
+ import noTruncatedDescription from "./no-truncated-description.js";
4
5
  const configs = {};
5
6
  /**
6
7
  * Manifests: every project's package.json declares the npm packages its
7
8
  * shipped code needs. How many depends on the project's shape: a bundled app
8
9
  * declares the whole closure its workspace imports pull in, an unbundled
9
10
  * project only its own imports. Islands are checked by
10
- * `island/dependency-checks`.
11
+ * `island/dependency-checks`. A manifest that npm can publish keeps its
12
+ * description inside what the npm registry stores.
11
13
  */
12
14
  const plugin = {
13
15
  meta: { name: '@zukhruf/eslint/nx/manifest', namespace: 'manifest' },
14
- rules: { 'dependency-checks': dependencyChecks },
16
+ rules: {
17
+ 'dependency-checks': dependencyChecks,
18
+ 'no-truncated-description': noTruncatedDescription,
19
+ },
15
20
  configs,
16
21
  };
17
22
  configs['recommended'] = [
@@ -20,7 +25,10 @@ configs['recommended'] = [
20
25
  name: 'manifest/recommended',
21
26
  files: PACKAGE_JSON,
22
27
  languageOptions: { parser: jsonc },
23
- rules: { 'manifest/dependency-checks': 'error' },
28
+ rules: {
29
+ 'manifest/dependency-checks': 'error',
30
+ 'manifest/no-truncated-description': 'error',
31
+ },
24
32
  },
25
33
  ];
26
34
  export default plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/manifest/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAA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AAE;IACvE;QACE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,YAAY;QACnB,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QAClC,KAAK,EAAE;YACL,4BAA4B,EAAE,OAAO;YACrC,mCAAmC,EAAE,OAAO;SAC7C;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zukhruf/eslint",
3
- "version": "0.3.53",
3
+ "version": "0.3.54",
4
4
  "description": "ESLint rules and configs shared across workspaces. Every check is its own named rule, so a repo's own config cannot silently erase it.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,7 +56,7 @@
56
56
  "ts-api-utils": "^2.5.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@zukhruf/testing": "^0.3.53"
59
+ "@zukhruf/testing": "^0.3.54"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@eslint/js": "^9.30.0 || ^10.0.0",