@micelio/eslint-config 0.2.4 → 0.2.5

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
@@ -30,3 +30,18 @@ version `AGENTS.md` pins (`` `standard: X.Y` ``), using the SHA-256 hashes in
30
30
  `@micelio/eslint-config/standard-hashes.json`. Add it as `"lint:standard": "micelio-lint-standard"`
31
31
  and to `npm run check`. A pinned version newer than the installed package knows fails with a message
32
32
  that says to upgrade the package.
33
+
34
+ ## `lint:ee`
35
+
36
+ `micelio-lint-ee [--allow <path>]... [root]` fails when a file git tracks enables Strapi Enterprise
37
+ code, which is not AGPL-compatible (bogd3v/micelio-cms#96). It reads the tracked files with an
38
+ extension of code or configuration (`.js`, `.ts` and their variants, `.json`, `.yml`, `.sh`,
39
+ `.env.example`, `Dockerfile`) line by line and reports `path:line message` for three rules:
40
+
41
+ - the line names `STRAPI_LICENSE` (sets or reads the Enterprise licence key);
42
+ - the line imports `@strapi/review-workflows` or `@strapi/content-releases`;
43
+ - the line imports Strapi code under `ee/` (`@strapi/<package>/ee`).
44
+
45
+ `--allow <path>` (repeatable) names a tracked file, relative to the root, that may mention them, such
46
+ as `THIRD-PARTY.md` or `package-lock.json`; nothing else is skipped. A repository without Strapi
47
+ passes. Add it as `"lint:ee": "micelio-lint-ee"` and to `npm run check`.
package/dist/ee.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /** One rule of `micelio-lint-ee`: a line that matches `pattern` fails with `message`. */
2
+ export interface EeRule {
3
+ /** The text that marks the line as Strapi Enterprise code. */
4
+ pattern: RegExp;
5
+ /** What the line does, as it appears in the report. */
6
+ message: string;
7
+ }
8
+ /**
9
+ * The three rules of `micelio-cms`'s `scripts/check-no-ee.mjs`, none dropped or narrowed
10
+ * (Strapi Enterprise code is not AGPL-compatible, bogd3v/micelio-cms#96).
11
+ */
12
+ export declare const EE_RULES: readonly EeRule[];
13
+ /** What `lintEe` found. */
14
+ export interface EeResult {
15
+ /** True when no scanned file matches a rule. */
16
+ ok: boolean;
17
+ /** One `path:line message` per match. */
18
+ failures: string[];
19
+ /** How many files were scanned. */
20
+ checked: number;
21
+ /** One line for the terminal. */
22
+ message: string;
23
+ }
24
+ /**
25
+ * Scans the files git tracks in `root` for Strapi Enterprise code.
26
+ *
27
+ * @param root - The repository directory.
28
+ * @param allow - The tracked paths, relative to `root`, that may name the patterns (a licence list, the lockfile).
29
+ * @returns The matches, one per line and rule.
30
+ */
31
+ export declare function lintEe(root: string, allow?: readonly string[]): EeResult;
package/dist/ee.js ADDED
@@ -0,0 +1,52 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ /**
5
+ * The three rules of `micelio-cms`'s `scripts/check-no-ee.mjs`, none dropped or narrowed
6
+ * (Strapi Enterprise code is not AGPL-compatible, bogd3v/micelio-cms#96).
7
+ */
8
+ export const EE_RULES = [
9
+ {
10
+ pattern: /STRAPI_LICENSE/,
11
+ message: 'sets or reads STRAPI_LICENSE (Strapi Enterprise license key)',
12
+ },
13
+ {
14
+ pattern: /['"]@strapi\/(review-workflows|content-releases)['"/]/,
15
+ message: 'imports a Strapi Enterprise package',
16
+ },
17
+ { pattern: /['"]@strapi\/[^'"]+\/ee(\/|['"])/, message: 'imports Strapi code under ee/' },
18
+ ];
19
+ /** The tracked files that can hold code or configuration: the ones the script of `micelio-cms` reads. */
20
+ const SCANNED = /\.(m?[jt]sx?|json|ya?ml|sh|env\.example)$|(^|\/)(Dockerfile|\.env\.example)$/;
21
+ /**
22
+ * Scans the files git tracks in `root` for Strapi Enterprise code.
23
+ *
24
+ * @param root - The repository directory.
25
+ * @param allow - The tracked paths, relative to `root`, that may name the patterns (a licence list, the lockfile).
26
+ * @returns The matches, one per line and rule.
27
+ */
28
+ export function lintEe(root, allow = []) {
29
+ const files = execFileSync('git', ['ls-files'], { cwd: root, encoding: 'utf8' })
30
+ .split('\n')
31
+ .filter((file) => file && !allow.includes(file) && SCANNED.test(file));
32
+ const failures = [];
33
+ for (const file of files) {
34
+ readFileSync(join(root, file), 'utf8')
35
+ .split('\n')
36
+ .forEach((line, index) => {
37
+ for (const rule of EE_RULES) {
38
+ if (rule.pattern.test(line))
39
+ failures.push(`${file}:${index + 1} ${rule.message}`);
40
+ }
41
+ });
42
+ }
43
+ const ok = failures.length === 0;
44
+ return {
45
+ ok,
46
+ failures,
47
+ checked: files.length,
48
+ message: ok
49
+ ? `No Strapi Enterprise code enabled (${files.length} files checked).`
50
+ : 'Strapi Enterprise code must stay disabled: see THIRD-PARTY.md.',
51
+ };
52
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { lintEe } from './ee.js';
3
+ // `micelio-lint-ee [--allow <path>]... [root]`: the `lint:ee` script of a repository born from `template/`.
4
+ const allow = [];
5
+ let root = process.cwd();
6
+ const args = process.argv.slice(2);
7
+ for (let i = 0; i < args.length; i++) {
8
+ const arg = args[i];
9
+ if (arg === '--allow') {
10
+ const path = args[++i];
11
+ if (path === undefined) {
12
+ console.error('error: --allow needs a path');
13
+ process.exit(2);
14
+ }
15
+ allow.push(path);
16
+ }
17
+ else {
18
+ root = arg;
19
+ }
20
+ }
21
+ const result = lintEe(root, allow);
22
+ if (result.ok) {
23
+ process.stdout.write(`${result.message}\n`);
24
+ }
25
+ else {
26
+ for (const failure of result.failures)
27
+ console.error(`error: ${failure}`);
28
+ console.error(result.message);
29
+ process.exitCode = 1;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micelio/eslint-config",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "The ESLint flat config of the Micelio repositories, the licence allowlist behind lint:licenses and lint:standard.",
5
5
  "license": "MIT-0",
6
6
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "provenance": true
46
46
  },
47
47
  "bin": {
48
+ "micelio-lint-ee": "./dist/lint-ee.js",
48
49
  "micelio-lint-standard": "./dist/lint-standard.js"
49
50
  },
50
51
  "devDependencies": {
@@ -6,7 +6,7 @@
6
6
  "1.8": "bbdbd8b0f7d394ba24471a3b65dbcf7a82b9899a221a39e78ffe819ebbc79249",
7
7
  "files": {
8
8
  ".claude/agents/master.md": "35e9ce4cc637ca814352916dd24e64f25da66f0c3c36fb492e2172c40e6d6416",
9
- ".claude/agents/planner.md": "944a55dae33c1f4290c574923d12af1d3b1f24c4cd5dfb75f4e819ca24ecb727",
9
+ ".claude/agents/planner.md": "548a7b62a14c0c07067004fb57934bf572e308063e3ed390262e1d7a69e9fea0",
10
10
  ".claude/agents/reviewer.md": "8edcd83631b191013217eb9f309b108f54e988708496182877077b65a9b6f1cf",
11
11
  ".claude/agents/verifier.md": "7fc1c73eec7c64ba669ece73075c0f967b316d81c9389a00ae729acf29505ae8",
12
12
  ".claude/agents/worker.md": "3f4dafea2266a752a5aba7f26035bdab1c5a4b6591916f0c2be4fdb68ad924ca",