File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed
Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const config = {
99 extends : [ require . resolve ( './react' ) ] ,
1010 rules : {
1111 '@liferay/portal/deprecation' : 'error' ,
12+ '@liferay/portal/empty-line-after-copyright' : 'error' ,
1213 '@liferay/portal/no-default-export-from-frontend-js-web' : 'error' ,
1314 '@liferay/portal/no-document-cookie' : 'error' ,
1415 '@liferay/portal/no-explicit-extend' : 'error' ,
Original file line number Diff line number Diff line change 55
66module . exports = {
77 'portal/deprecation' : require ( './lib/rules/deprecation' ) ,
8+ 'portal/empty-line-after-copyright' : require ( './lib/rules/empty-line-after-copyright' ) ,
89 'portal/no-default-export-from-frontend-js-web' : require ( './lib/rules/no-default-export-from-frontend-js-web' ) ,
910 'portal/no-document-cookie' : require ( './lib/rules/no-document-cookie' ) ,
1011 'portal/no-explicit-extend' : require ( './lib/rules/no-explicit-extend' ) ,
Original file line number Diff line number Diff line change 1+ /**
2+ * SPDX-FileCopyrightText: © 2021 Liferay, Inc. <https://liferay.com>
3+ * SPDX-License-Identifier: MIT
4+ */
5+
6+ const message = 'Expected an empty line after the copyright notice.' ;
7+
8+ module . exports = {
9+ create ( context ) {
10+ return {
11+ Program ( ) {
12+ const comments = context . getSourceCode ( ) . getAllComments ( ) ;
13+
14+ const copyrightComment = comments . find ( ( item ) =>
15+ item . value . match ( 'SPDX-FileCopyrightText:' )
16+ ) ;
17+
18+ if ( ! copyrightComment ) {
19+ return ;
20+ }
21+
22+ const endLine = copyrightComment . loc . end . line ;
23+
24+ const firstNode = context . getSourceCode ( ) . ast . body [ 0 ] ;
25+
26+ if ( firstNode && firstNode . loc . start . line === endLine + 1 ) {
27+ context . report ( {
28+ fix : ( fixer ) => {
29+ return fixer . insertTextAfter (
30+ copyrightComment ,
31+ '\n'
32+ ) ;
33+ } ,
34+ message,
35+ node : firstNode ,
36+ } ) ;
37+ }
38+ } ,
39+ } ;
40+ } ,
41+
42+ meta : {
43+ docs : {
44+ category : 'Best Practices' ,
45+ description : message ,
46+ recommended : false ,
47+ } ,
48+ fixable : 'code' ,
49+ schema : [ ] ,
50+ type : 'problem' ,
51+ } ,
52+ } ;
You can’t perform that action at this time.
0 commit comments