@diplodoc/lint 1.9.1 → 1.10.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.
@@ -0,0 +1,49 @@
1
+ COMMIT_MSG_FILE="$1"
2
+ COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
3
+
4
+ # Check if commit message contains Cyrillic characters
5
+ # All commit messages must be in English per .agents/style-and-testing.md
6
+ if echo "$COMMIT_MSG" | grep -q '[А-Яа-яЁё]'; then
7
+ echo "❌ Error: Commit message contains Cyrillic characters."
8
+ echo ""
9
+ echo "All commit messages must be in English per .agents/style-and-testing.md"
10
+ echo "Please rewrite your commit message in English."
11
+ echo ""
12
+ echo "Current commit message:"
13
+ echo "$COMMIT_MSG"
14
+ exit 1
15
+ fi
16
+
17
+ # Extract the first line (subject) of commit message
18
+ SUBJECT=$(echo "$COMMIT_MSG" | head -n1)
19
+
20
+ # Allow fixup! and squash! prefixes (for git commit --fixup and --squash)
21
+ if echo "$SUBJECT" | grep -qE '^(fixup!|squash!)'; then
22
+ exit 0
23
+ fi
24
+
25
+ # Check Conventional Commits format: <type>(<scope>): <subject>
26
+ # Types: feat, fix, perf, refactor, docs, chore, revert
27
+ # Scope is optional
28
+ if ! echo "$SUBJECT" | grep -qE '^(feat|fix|perf|refactor|docs|chore|revert)(\([^)]+\))?: .+'; then
29
+ echo "❌ Error: Commit message does not follow Conventional Commits format."
30
+ echo ""
31
+ echo "Expected format: <type>(<scope>): <subject>"
32
+ echo ""
33
+ echo "Types: feat, fix, perf, refactor, docs, chore, revert"
34
+ echo "Scope is optional"
35
+ echo ""
36
+ echo "Examples:"
37
+ echo " feat(cli): add new command"
38
+ echo " fix(transform): handle edge case"
39
+ echo " docs(readme): update installation"
40
+ echo ""
41
+ echo "For fixing previous commits, use:"
42
+ echo " fixup! <original commit message>"
43
+ echo ""
44
+ echo "Current commit message:"
45
+ echo "$SUBJECT"
46
+ exit 1
47
+ fi
48
+
49
+ exit 0
package/.lintstagedrc.js CHANGED
@@ -8,16 +8,14 @@ const {readFileSync} = require('node:fs');
8
8
  const {join} = require('node:path');
9
9
 
10
10
  // Check if this is the @diplodoc/lint package itself
11
- function isLintPackage() {
11
+ const isLintPkg = (() => {
12
12
  try {
13
- const packageJson = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
14
- return packageJson.name === '@diplodoc/lint';
13
+ const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
14
+ return pkg.name === '@diplodoc/lint';
15
15
  } catch {
16
16
  return false;
17
17
  }
18
- }
19
-
20
- const isLintPkg = isLintPackage();
18
+ })();
21
19
 
22
20
  module.exports = {
23
21
  // Exclude config files from linting (they use CommonJS)
@@ -33,15 +31,17 @@ module.exports = {
33
31
  const filtered = filenames.filter(
34
32
  (f) =>
35
33
  !configFiles.some((config) => f.includes(config)) &&
36
- // For @diplodoc/lint package itself: exclude bin/ (internal scripts)
37
- !(isLintPkg && f.includes('bin/')),
34
+ // For @diplodoc/lint package itself: exclude bin/ and scripts/ (in .eslintignore)
35
+ !(isLintPkg && (f.includes('bin/') || f.includes('scripts/'))),
38
36
  );
39
37
  if (filtered.length === 0) {
40
38
  return [];
41
39
  }
42
40
  return [
43
41
  ...filtered.map((f) => `prettier --write ${f}`),
44
- ...filtered.map((f) => `eslint --max-warnings=0 --fix ${f}`),
42
+ ...filtered.map(
43
+ (f) => `env ESLINT_USE_FLAT_CONFIG=false npx eslint --max-warnings=0 --fix ${f}`,
44
+ ),
45
45
  ];
46
46
  },
47
47
  // Handle .lintstagedrc.js separately (only prettier, no eslint)
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.9.1"
2
+ ".": "1.10.0"
3
3
  }
package/AGENTS.md CHANGED
@@ -42,6 +42,7 @@ This file contains instructions for AI agents working with the `@diplodoc/lint`
42
42
  - `.stylelintrc.js` — Stylelint configuration template
43
43
  - `.lintstagedrc.js` — lint-staged configuration template
44
44
  - `.husky/pre-commit` — Husky pre-commit hook template
45
+ - `.husky/commit-msg` — Husky commit-msg hook template (validates commit messages are in English)
45
46
  - `scripts/` — helper scripts for package.json and .ignore file modification
46
47
  - `modify-package.js` — adds lint scripts to package.json
47
48
  - `modify-ignore.js` — updates .ignore files with standard patterns
@@ -413,6 +414,13 @@ Files in `scaffolding/` are copied to packages during `init`/`update`:
413
414
 
414
415
  - Runs `npm run pre-commit` before each commit
415
416
  - Pre-commit script runs `lint update && lint-staged`
417
+
418
+ **`.husky/commit-msg`**:
419
+
420
+ - Validates that commit messages follow Conventional Commits format (per `.agents/style-and-testing.md`)
421
+ - Validates that commit messages are in English (rejects Cyrillic characters)
422
+ - Allows `fixup!` and `squash!` prefixes for git commit --fixup/--squash
423
+ - Provides helpful error messages with examples and reference to style guide
416
424
  - lint-staged automatically runs unit tests when relevant files are changed
417
425
 
418
426
  **Ignore Files** (updated via `modify-ignore.js`):
@@ -487,13 +495,11 @@ npm run test:old
487
495
  ## Code Conventions
488
496
 
489
497
  1. **File naming**:
490
-
491
498
  - Config files: `*-config.js` (e.g., `eslint-common-config.js`)
492
499
  - Scripts: `modify-*.js` in `scripts/` directory
493
500
  - Binaries: executable scripts in `bin/` directory
494
501
 
495
502
  2. **Comments and documentation**:
496
-
497
503
  - **All code comments must be in English**
498
504
  - **All documentation files (ADR, AGENTS.md, README, etc.) must be in English**
499
505
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.0](https://github.com/diplodoc-platform/lint/compare/v1.9.2...v1.10.0) (2026-01-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * **lint:** add commit-msg hook for validation ([06aa520](https://github.com/diplodoc-platform/lint/commit/06aa520e80c189116d891d7dc3b48535cf479d3d))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **lint:** remove deprecated husky lines from commit-msg hook ([6aca178](https://github.com/diplodoc-platform/lint/commit/6aca178046d0d55eceee0f3341c6b46eb1c570e4))
14
+
15
+ ## [1.9.2](https://github.com/diplodoc-platform/lint/compare/v1.9.1...v1.9.2) (2025-12-29)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * use ESLINT_USE_FLAT_CONFIG=false in lint-staged ([88a17b6](https://github.com/diplodoc-platform/lint/commit/88a17b62a791cc491f195ed66b69f63964f89f9b))
21
+
3
22
  ## [1.9.1](https://github.com/diplodoc-platform/lint/compare/v1.9.0...v1.9.1) (2025-12-29)
4
23
 
5
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/lint",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "Diplodoc platform internal utility set for linting",
5
5
  "bin": {
6
6
  "lint": "./bin/lint.js",
@@ -0,0 +1,49 @@
1
+ COMMIT_MSG_FILE="$1"
2
+ COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
3
+
4
+ # Check if commit message contains Cyrillic characters
5
+ # All commit messages must be in English per .agents/style-and-testing.md
6
+ if echo "$COMMIT_MSG" | grep -q '[А-Яа-яЁё]'; then
7
+ echo "❌ Error: Commit message contains Cyrillic characters."
8
+ echo ""
9
+ echo "All commit messages must be in English per .agents/style-and-testing.md"
10
+ echo "Please rewrite your commit message in English."
11
+ echo ""
12
+ echo "Current commit message:"
13
+ echo "$COMMIT_MSG"
14
+ exit 1
15
+ fi
16
+
17
+ # Extract the first line (subject) of commit message
18
+ SUBJECT=$(echo "$COMMIT_MSG" | head -n1)
19
+
20
+ # Allow fixup! and squash! prefixes (for git commit --fixup and --squash)
21
+ if echo "$SUBJECT" | grep -qE '^(fixup!|squash!)'; then
22
+ exit 0
23
+ fi
24
+
25
+ # Check Conventional Commits format: <type>(<scope>): <subject>
26
+ # Types: feat, fix, perf, refactor, docs, chore, revert
27
+ # Scope is optional
28
+ if ! echo "$SUBJECT" | grep -qE '^(feat|fix|perf|refactor|docs|chore|revert)(\([^)]+\))?: .+'; then
29
+ echo "❌ Error: Commit message does not follow Conventional Commits format."
30
+ echo ""
31
+ echo "Expected format: <type>(<scope>): <subject>"
32
+ echo ""
33
+ echo "Types: feat, fix, perf, refactor, docs, chore, revert"
34
+ echo "Scope is optional"
35
+ echo ""
36
+ echo "Examples:"
37
+ echo " feat(cli): add new command"
38
+ echo " fix(transform): handle edge case"
39
+ echo " docs(readme): update installation"
40
+ echo ""
41
+ echo "For fixing previous commits, use:"
42
+ echo " fixup! <original commit message>"
43
+ echo ""
44
+ echo "Current commit message:"
45
+ echo "$SUBJECT"
46
+ exit 1
47
+ fi
48
+
49
+ exit 0
@@ -8,16 +8,14 @@ const {readFileSync} = require('node:fs');
8
8
  const {join} = require('node:path');
9
9
 
10
10
  // Check if this is the @diplodoc/lint package itself
11
- function isLintPackage() {
11
+ const isLintPkg = (() => {
12
12
  try {
13
- const packageJson = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
14
- return packageJson.name === '@diplodoc/lint';
13
+ const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));
14
+ return pkg.name === '@diplodoc/lint';
15
15
  } catch {
16
16
  return false;
17
17
  }
18
- }
19
-
20
- const isLintPkg = isLintPackage();
18
+ })();
21
19
 
22
20
  module.exports = {
23
21
  // Exclude config files from linting (they use CommonJS)
@@ -33,15 +31,17 @@ module.exports = {
33
31
  const filtered = filenames.filter(
34
32
  (f) =>
35
33
  !configFiles.some((config) => f.includes(config)) &&
36
- // For @diplodoc/lint package itself: exclude bin/ (internal scripts)
37
- !(isLintPkg && f.includes('bin/')),
34
+ // For @diplodoc/lint package itself: exclude bin/ and scripts/ (in .eslintignore)
35
+ !(isLintPkg && (f.includes('bin/') || f.includes('scripts/'))),
38
36
  );
39
37
  if (filtered.length === 0) {
40
38
  return [];
41
39
  }
42
40
  return [
43
41
  ...filtered.map((f) => `prettier --write ${f}`),
44
- ...filtered.map((f) => `eslint --max-warnings=0 --fix ${f}`),
42
+ ...filtered.map(
43
+ (f) => `env ESLINT_USE_FLAT_CONFIG=false npx eslint --max-warnings=0 --fix ${f}`,
44
+ ),
45
45
  ];
46
46
  },
47
47
  // Handle .lintstagedrc.js separately (only prettier, no eslint)
@@ -20,22 +20,6 @@ const INSTALL = [
20
20
  'node_modules',
21
21
  ];
22
22
 
23
- // Check if this is the @diplodoc/lint package itself
24
- function isLintPackage() {
25
- try {
26
- const packageJsonPath = join(process.cwd(), 'package.json');
27
- if (!existsSync(packageJsonPath)) {
28
- return false;
29
- }
30
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
31
- return packageJson.name === '@diplodoc/lint';
32
- } catch {
33
- return false;
34
- }
35
- }
36
-
37
- const isLintPkg = isLintPackage();
38
-
39
23
  const ignores = {
40
24
  '.gitignore': [
41
25
  ...SYSTEM,
@@ -53,8 +37,6 @@ const ignores = {
53
37
  '.stylelintrc.js',
54
38
  // Build scripts that use newer syntax not yet supported by ESLint parser
55
39
  'esbuild/**/*.mjs',
56
- // For @diplodoc/lint package itself: bin/ contains internal scripts
57
- ...(isLintPkg ? ['bin/'] : []),
58
40
  ],
59
41
  '.prettierignore': [
60
42
  ...SYSTEM,
@@ -32,27 +32,18 @@ const configContent = configTemplate
32
32
 
33
33
  const manifestContent = manifestTemplate
34
34
  .replace(/\{\{PACKAGE_VERSION\}\}/g, packageVersion)
35
- .trimEnd(); // Remove trailing whitespace/newlines
35
+ .trimEnd() + '\n'; // Remove trailing whitespace/newlines
36
36
 
37
37
  // Write files
38
38
  const configOutputPath = join(process.cwd(), '.release-please-config.json');
39
39
  const manifestOutputPath = join(process.cwd(), '.release-please-manifest.json');
40
40
 
41
- // Only create if they don't exist (preserve existing configs)
42
41
  if (!existsSync(configOutputPath)) {
43
- writeFileSync(configOutputPath, configContent, 'utf8');
44
42
  console.log('[@diplodoc/lint]', '=> Create .release-please-config.json');
45
- } else {
46
- console.log('[@diplodoc/lint]', '=> .release-please-config.json already exists, skipping');
43
+ writeFileSync(configOutputPath, configContent, 'utf8');
47
44
  }
48
45
 
49
- if (!existsSync(manifestOutputPath)) {
50
- writeFileSync(manifestOutputPath, manifestContent, 'utf8');
51
- console.log('[@diplodoc/lint]', '=> Create .release-please-manifest.json');
52
- } else {
53
- // Always update manifest with current version
54
- writeFileSync(manifestOutputPath, manifestContent, 'utf8');
55
- console.log('[@diplodoc/lint]', '=> Update .release-please-manifest.json');
56
- }
46
+ console.log('[@diplodoc/lint]', '=> Update .release-please-manifest.json');
47
+ writeFileSync(manifestOutputPath, manifestContent, 'utf8');
57
48
 
58
49