Skip to content

Commit c3ad224

Browse files
authored
Merge pull request #18827 from ckeditor/ck/18777-lint-changelog-entries
Lint changelog entries
2 parents 132f5b4 + 2fb31d5 commit c3ad224

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

docs/framework/contributing/code-style.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,3 +1224,7 @@ import { AIAssistant } from 'ckeditor5-premium-features';
12241224
### SVG imports only in the `@ckeditor/ckeditor5-icons` package
12251225

12261226
This rule ensures that SVG files are imported and exported only in the `@ckeditor/ckeditor5-icons` package. This package should include all icons used in CKEditor 5.
1227+
1228+
### Valid changelog entries
1229+
1230+
This rule ensures that changelog entry files are populated with proper data and a clear description of the change. For a full guide on how to populate changelog entries, see the {@link framework/contributing/changelog-entries Changelog entries} guide.

eslint.config.mjs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,29 @@
33
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
44
*/
55

6+
import { readdirSync } from 'fs';
67
import globals from 'globals';
78
import { defineConfig } from 'eslint/config';
89
import ckeditor5Rules from 'eslint-plugin-ckeditor5-rules';
910
import ckeditor5Config from 'eslint-config-ckeditor5';
1011
import ts from 'typescript-eslint';
1112
import eslintPluginImport from 'eslint-plugin-import';
12-
1313
import rootPkgJson from './package.json' with { type: 'json' };
14+
import { CKEDITOR5_PACKAGES_PATH } from './scripts/constants.mjs';
1415

1516
const disallowedImports = Object.keys( rootPkgJson.devDependencies ).filter( pkgName => {
1617
return pkgName.match( /^(@ckeditor\/)?ckeditor5-(?!dev-)/ );
1718
} );
1819

20+
const projectPackages = readdirSync( CKEDITOR5_PACKAGES_PATH, { withFileTypes: true } )
21+
.filter( dirent => dirent.isDirectory() )
22+
.map( dirent => dirent.name );
23+
1924
export default defineConfig( [
2025
{
2126
ignores: [
2227
'.*/',
28+
'!.changelog/',
2329
'build/**',
2430
'coverage/**',
2531
'dist/**',
@@ -179,5 +185,24 @@ export default defineConfig( [
179185
rules: {
180186
'ckeditor5-rules/ckeditor-imports': 'off'
181187
}
188+
},
189+
{
190+
extends: ckeditor5Config,
191+
192+
files: [ '.changelog/**/*.md' ],
193+
194+
plugins: {
195+
'ckeditor5-rules': ckeditor5Rules
196+
},
197+
198+
rules: {
199+
'ckeditor5-rules/validate-changelog-entry': [ 'error', {
200+
allowedScopes: [
201+
...projectPackages,
202+
'ckeditor5'
203+
],
204+
repositoryType: 'mono'
205+
} ]
206+
}
182207
}
183208
] );

scripts/constants.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
*/
55

66
import upath from 'upath';
7-
import { fileURLToPath } from 'url';
87
import { PACKAGES_DIRECTORY } from './release/utils/constants.mjs';
9-
const __filename = fileURLToPath( import.meta.url );
10-
const __dirname = upath.dirname( __filename );
118

12-
export const CKEDITOR5_ROOT_PATH = upath.join( __dirname, '..' );
9+
export const CKEDITOR5_ROOT_PATH = upath.join( import.meta.dirname, '..' );
10+
export const CKEDITOR5_PACKAGES_PATH = upath.join( CKEDITOR5_ROOT_PATH, PACKAGES_DIRECTORY );
1311
export const CKEDITOR5_COMMERCIAL_PATH = upath.join( CKEDITOR5_ROOT_PATH, 'external', 'ckeditor5-commercial' );
14-
export const CKEDITOR5_PREMIUM_FEATURES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PATH, PACKAGES_DIRECTORY, 'ckeditor5-premium-features' );
12+
export const CKEDITOR5_COMMERCIAL_PACKAGES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PATH, PACKAGES_DIRECTORY );
13+
export const CKEDITOR5_PREMIUM_FEATURES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PACKAGES_PATH, 'ckeditor5-premium-features' );
1514

1615
export const CKEDITOR5_INDEX = upath.join( CKEDITOR5_ROOT_PATH, 'src', 'index.ts' );
1716
export const CKEDITOR5_PREMIUM_FEATURES_INDEX = upath.join( CKEDITOR5_PREMIUM_FEATURES_PATH, 'src', 'index.ts' );

0 commit comments

Comments
 (0)