Skip to content

Commit

Permalink
Make a CJS formatter compatible with an ESM only chalk.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Sep 23, 2024
1 parent ef451e3 commit 39c2c38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
ignorePatterns: [
// The CKEditor 5 core DLL build is created from JavaScript files.
// ESLint should not process compiled TypeScript.
'src/*.js'
'src/*.js',
'**/*.d.ts'
],
rules: {
'ckeditor5-rules/ckeditor-imports': 'error',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
},
"scripts": {
"postinstall": "node ./scripts/postinstall.mjs",
"lint": "eslint --quiet \"**/*.{js,ts,mjs}\" --format ./scripts/eslint-formatter.cjs",
"lint": "eslint --quiet \"**/*.{js,ts,mjs,cjs}\" --format ./scripts/eslint-formatter.cjs",
"stylelint": "stylelint --quiet --allow-empty-input \"packages/**/*.css\" \"docs/**/*.css\"",
"test": "node --max_old_space_size=4096 node_modules/@ckeditor/ckeditor5-dev-tests/bin/testautomated.js",
"manual": "node --max_old_space_size=8192 node_modules/@ckeditor/ckeditor5-dev-tests/bin/testmanual.js",
Expand Down
5 changes: 3 additions & 2 deletions scripts/eslint-formatter.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// See: https://eslint.org/docs/user-guide/formatters/#stylish.
const eslintStylishFormatter = require( 'eslint-formatter-stylish' );
const chalk = require( 'chalk' );

// eslint-disable-next-line max-len
const CODE_STYLE_URL = 'https://ckeditor.com/docs/ckeditor5/latest/framework/contributing/code-style.html#ckeditor-5-custom-eslint-rules';
Expand All @@ -20,7 +19,7 @@ const CODE_STYLE_URL = 'https://ckeditor.com/docs/ckeditor5/latest/framework/con
*
* @param {Array} results
*/
module.exports = results => {
module.exports = async results => {
console.log( eslintStylishFormatter( results ) );

const hasCKEditorErrors = results.some( item => {
Expand All @@ -37,6 +36,8 @@ module.exports = results => {
return;
}

const { default: chalk } = await import( 'chalk' );

console.log( chalk.cyan( 'CKEditor 5 custom ESLint rules are described in the "Code style" guide in the documentation.' ) );
console.log( chalk.underline( CODE_STYLE_URL ) );
console.log( '' );
Expand Down

0 comments on commit 39c2c38

Please sign in to comment.