Skip to content

Commit 0d48344

Browse files
pedrottimarkjeysal
authored andcommitted
chore: Check copyright and license as one joined substring (#8815)
* chore: Check copyright and license as one joined substring * Update CHANGELOG.md * Delete misleading comment
1 parent 9406708 commit 0d48344

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- `[jest-core]` Add `getVersion` (moved from `jest-cli`) ([#8706](https://github.com/facebook/jest/pull/8706))
5353
- `[docs]` Fix MockFunctions example that was using toContain instead of toContainEqual ([#8765](https://github.com/facebook/jest/pull/8765))
5454
- `[*]` Make sure copyright header comment includes license ([#8783](https://github.com/facebook/jest/pull/8783))
55+
- `[*]` Check copyright and license as one joined substring ([#8815](https://github.com/facebook/jest/pull/8815))
5556
- `[docs]` Fix WatchPlugins `jestHooks.shouldRunTestSuite` example that receives an object ([#8784](https://github.com/facebook/jest/pull/8784))
5657
- `[*]` Enforce LF line endings ([#8809](https://github.com/facebook/jest/pull/8809))
5758

scripts/checkCopyrightHeaders.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,16 @@ const INCLUDED_PATTERNS = [
115115
/\.[^/]+$/,
116116
];
117117

118-
const COPYRIGHT_HEADER =
119-
'Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.';
120-
const LICENSE1 =
121-
'This source code is licensed under the MIT license found in the';
122-
const LICENSE2 = 'LICENSE file in the root directory of this source tree.';
118+
const COPYRIGHT_LICENSE = [
119+
' * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.',
120+
' *',
121+
' * This source code is licensed under the MIT license found in the',
122+
' * LICENSE file in the root directory of this source tree.',
123+
].join('\n');
123124

124125
function needsCopyrightHeader(file) {
125126
const contents = getFileContents(file);
126-
127-
// Match lines individually to avoid false positive for:
128-
// comment block versus lines
129-
// line ending LF versus CRLF
130-
return (
131-
contents.trim().length > 0 &&
132-
(!contents.includes(COPYRIGHT_HEADER) ||
133-
!contents.includes(LICENSE1) ||
134-
!contents.includes(LICENSE2))
135-
);
127+
return contents.trim().length > 0 && !contents.includes(COPYRIGHT_LICENSE);
136128
}
137129

138130
function check() {

0 commit comments

Comments
 (0)