-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ckeditor/ck/11473
Feature (eslint-plugin-ckeditor5-rules): Added fixer for the `license-header` rule. Closes ckeditor/ckeditor5#11473. Tests (eslint-plugin-ckeditor5-rules): Added support for using fixtures in tests. Currently only implemented in the `license-header` rule tests. Closes ckeditor/ckeditor5#11473.
- Loading branch information
Showing
32 changed files
with
391 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ module.exports = { | |
}, | ||
rules: { | ||
'no-console': 'off' | ||
} | ||
}, | ||
ignorePatterns: [ 'fixtures' ] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/eslint-plugin-ckeditor5-rules/tests/fixture-loader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
const fs = require( 'fs' ); | ||
const path = require( 'path' ); | ||
|
||
const fixtureTypes = [ | ||
'valid', | ||
'invalid' | ||
]; | ||
|
||
module.exports = function fixtureLoader( ruleName ) { | ||
const fixtures = {}; | ||
|
||
for ( const fixtureType of fixtureTypes ) { | ||
const typeDir = path.join( __dirname, 'fixtures', ruleName, fixtureType ); | ||
|
||
fixtures[ fixtureType ] = fs.readdirSync( typeDir ).reduce( ( output, filename ) => { | ||
const fixturePath = path.join( typeDir, filename ); | ||
const fixtureContent = fs.readFileSync( fixturePath, 'utf-8' ); | ||
const fixtureKey = filename | ||
.replace( '.js', '' ) | ||
.replace( /-/g, '_' ); | ||
|
||
output[ fixtureKey ] = fixtureContent; | ||
|
||
return output; | ||
}, {} ); | ||
} | ||
|
||
return fixtures; | ||
}; |
6 changes: 6 additions & 0 deletions
6
...ages/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/all-uppercase.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @LICENSE COPYRIGHT (C) 2003-2022, CKSOURCE HOLDING SP. Z O.O. ALL RIGHTS RESERVED. | ||
* FOR LICENSING, SEE LICENSE.MD OR HTTPS://CKEDITOR.COM/LEGAL/CKEDITOR-OSS-LICENSE | ||
*/ | ||
|
||
foo(); |
7 changes: 7 additions & 0 deletions
7
...gin-ckeditor5-rules/tests/fixtures/license-header/invalid/block-comment-before-license.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** foo */ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo() |
10 changes: 10 additions & 0 deletions
10
...-ckeditor5-rules/tests/fixtures/license-header/invalid/code-between-shebang-and-header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
foo(); | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
1 change: 1 addition & 0 deletions
1
packages/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/code-only.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo(); |
10 changes: 10 additions & 0 deletions
10
...editor5-rules/tests/fixtures/license-header/invalid/comment-between-shebang-and-header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
// Comment. | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
4 changes: 4 additions & 0 deletions
4
...ditor5-rules/tests/fixtures/license-header/invalid/incorrect-license-whitespace-before.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
/** | ||
* @license TODO | ||
*/ |
4 changes: 4 additions & 0 deletions
4
packages/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/line-comment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
// For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
|
||
foo(); |
6 changes: 6 additions & 0 deletions
6
packages/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/missing-tag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* missing license tag 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
7 changes: 7 additions & 0 deletions
7
...t-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/shebang-without-newline.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
5 changes: 5 additions & 0 deletions
5
...s/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/whitespace-after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
foo(); |
6 changes: 6 additions & 0 deletions
6
...ugin-ckeditor5-rules/tests/fixtures/license-header/invalid/whitespace-before-and-after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
foo(); |
7 changes: 7 additions & 0 deletions
7
.../eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/invalid/whitespace-before.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
11 changes: 11 additions & 0 deletions
11
...ugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-and-header-without-tag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/** | ||
* missing license tag 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
9 changes: 9 additions & 0 deletions
9
...gin-ckeditor5-rules/tests/fixtures/license-header/valid/header-and-line-comment-header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
// @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
// For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
|
||
foo(); |
5 changes: 5 additions & 0 deletions
5
...slint-plugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-and-whitespace.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
4 changes: 4 additions & 0 deletions
4
packages/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-only.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ |
6 changes: 6 additions & 0 deletions
6
...ges/eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-with-code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
8 changes: 8 additions & 0 deletions
8
...lugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-with-shebang-and-code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
foo(); |
6 changes: 6 additions & 0 deletions
6
.../eslint-plugin-ckeditor5-rules/tests/fixtures/license-header/valid/header-with-shebang.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ |
Oops, something went wrong.