From e75cf07e22a28d6a8eea3ed1cfe4a8a016b5c014 Mon Sep 17 00:00:00 2001 From: Filip Sobol Date: Wed, 9 Jul 2025 09:42:23 +0200 Subject: [PATCH 1/3] Lint changelog entries --- eslint.config.mjs | 24 +++++++++++++++++++++++- scripts/constants.mjs | 4 +++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 138a4d6f836..a3271e4d7f9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -3,23 +3,29 @@ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ +import { readdirSync } from 'fs'; import globals from 'globals'; import { defineConfig } from 'eslint/config'; import ckeditor5Rules from 'eslint-plugin-ckeditor5-rules'; import ckeditor5Config from 'eslint-config-ckeditor5'; import ts from 'typescript-eslint'; import eslintPluginImport from 'eslint-plugin-import'; - import rootPkgJson from './package.json' with { type: 'json' }; +import { CKEDITOR5_PACKAGES_PATH } from './scripts/constants.mjs'; const disallowedImports = Object.keys( rootPkgJson.devDependencies ).filter( pkgName => { return pkgName.match( /^(@ckeditor\/)?ckeditor5-(?!dev-)/ ); } ); +const projectPackages = readdirSync( CKEDITOR5_PACKAGES_PATH, { withFileTypes: true } ) + .filter( dirent => dirent.isDirectory() ) + .map( dirent => dirent.name ); + export default defineConfig( [ { ignores: [ '.*/', + '!.changelog/', 'build/**', 'coverage/**', 'dist/**', @@ -179,5 +185,21 @@ export default defineConfig( [ rules: { 'ckeditor5-rules/ckeditor-imports': 'off' } + }, + { + extends: ckeditor5Config, + + files: [ '.changelog/**/*.md' ], + + plugins: { + 'ckeditor5-rules': ckeditor5Rules + }, + + rules: { + 'ckeditor5-rules/validate-changelog-entry': [ 'error', { + allowedScopes: projectPackages, + repositoryType: 'mono' + } ] + } } ] ); diff --git a/scripts/constants.mjs b/scripts/constants.mjs index d9e7e5360f2..90e4a13bfab 100644 --- a/scripts/constants.mjs +++ b/scripts/constants.mjs @@ -10,8 +10,10 @@ const __filename = fileURLToPath( import.meta.url ); const __dirname = upath.dirname( __filename ); export const CKEDITOR5_ROOT_PATH = upath.join( __dirname, '..' ); +export const CKEDITOR5_PACKAGES_PATH = upath.join( CKEDITOR5_ROOT_PATH, PACKAGES_DIRECTORY ); export const CKEDITOR5_COMMERCIAL_PATH = upath.join( CKEDITOR5_ROOT_PATH, 'external', 'ckeditor5-commercial' ); -export const CKEDITOR5_PREMIUM_FEATURES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PATH, PACKAGES_DIRECTORY, 'ckeditor5-premium-features' ); +export const CKEDITOR5_COMMERCIAL_PACKAGES_PATH = upath.join( CKEDITOR5_ROOT_PATH, PACKAGES_DIRECTORY ); +export const CKEDITOR5_PREMIUM_FEATURES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PACKAGES_PATH, 'ckeditor5-premium-features' ); export const CKEDITOR5_INDEX = upath.join( CKEDITOR5_ROOT_PATH, 'src', 'index.ts' ); export const CKEDITOR5_PREMIUM_FEATURES_INDEX = upath.join( CKEDITOR5_PREMIUM_FEATURES_PATH, 'src', 'index.ts' ); From 300be20378fe2d4217bbddf0e64ab1989c3283ea Mon Sep 17 00:00:00 2001 From: Filip Sobol Date: Thu, 10 Jul 2025 10:26:21 +0200 Subject: [PATCH 2/3] Update based on review feedback. --- eslint.config.mjs | 5 ++++- scripts/constants.mjs | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index a3271e4d7f9..66b33d9add2 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -197,7 +197,10 @@ export default defineConfig( [ rules: { 'ckeditor5-rules/validate-changelog-entry': [ 'error', { - allowedScopes: projectPackages, + allowedScopes: [ + ...projectPackages, + 'ckeditor5' + ], repositoryType: 'mono' } ] } diff --git a/scripts/constants.mjs b/scripts/constants.mjs index 90e4a13bfab..4a810c3bd93 100644 --- a/scripts/constants.mjs +++ b/scripts/constants.mjs @@ -4,15 +4,12 @@ */ import upath from 'upath'; -import { fileURLToPath } from 'url'; import { PACKAGES_DIRECTORY } from './release/utils/constants.mjs'; -const __filename = fileURLToPath( import.meta.url ); -const __dirname = upath.dirname( __filename ); -export const CKEDITOR5_ROOT_PATH = upath.join( __dirname, '..' ); +export const CKEDITOR5_ROOT_PATH = upath.join( import.meta.dirname, '..' ); export const CKEDITOR5_PACKAGES_PATH = upath.join( CKEDITOR5_ROOT_PATH, PACKAGES_DIRECTORY ); export const CKEDITOR5_COMMERCIAL_PATH = upath.join( CKEDITOR5_ROOT_PATH, 'external', 'ckeditor5-commercial' ); -export const CKEDITOR5_COMMERCIAL_PACKAGES_PATH = upath.join( CKEDITOR5_ROOT_PATH, PACKAGES_DIRECTORY ); +export const CKEDITOR5_COMMERCIAL_PACKAGES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PATH, PACKAGES_DIRECTORY ); export const CKEDITOR5_PREMIUM_FEATURES_PATH = upath.join( CKEDITOR5_COMMERCIAL_PACKAGES_PATH, 'ckeditor5-premium-features' ); export const CKEDITOR5_INDEX = upath.join( CKEDITOR5_ROOT_PATH, 'src', 'index.ts' ); From 2fb31d57c98e57eb336c21be234586b2a6cd46b4 Mon Sep 17 00:00:00 2001 From: Filip Sobol Date: Thu, 10 Jul 2025 10:40:53 +0200 Subject: [PATCH 3/3] Add new ESLint rule to `Code style` guide. --- docs/framework/contributing/code-style.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/framework/contributing/code-style.md b/docs/framework/contributing/code-style.md index 656f07a37dc..7505f7f48fa 100644 --- a/docs/framework/contributing/code-style.md +++ b/docs/framework/contributing/code-style.md @@ -1224,3 +1224,7 @@ import { AIAssistant } from 'ckeditor5-premium-features'; ### SVG imports only in the `@ckeditor/ckeditor5-icons` package 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. + +### Valid changelog entries + +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.