-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy patheslint-formatter.cjs
44 lines (34 loc) · 1.32 KB
/
eslint-formatter.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
'use strict';
/* eslint-env node */
// See: https://eslint.org/docs/user-guide/formatters/#stylish.
const eslintStylishFormatter = require( 'eslint-formatter-stylish' );
// 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';
/**
* Overwrite the default ESLint formatter. If CKEditor 5 related error occurred,
* let's print a URL to the documentation where all custom rules are explained.
*
* @param {Array} results
*/
module.exports = async results => {
console.log( eslintStylishFormatter( results ) );
const hasCKEditorErrors = results.some( item => {
if ( !Array.isArray( item.messages ) ) {
return false;
}
return item.messages.some( message => {
return message.ruleId?.startsWith( 'ckeditor5-rules' );
} );
} );
if ( !hasCKEditorErrors ) {
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( '' );
};