From 31aa3d130b5f4d28e30d125f2c289a4e029ff92f Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 12 Aug 2019 17:03:29 -0400 Subject: [PATCH 1/3] chore: Check copyright and license as one joined substring --- scripts/checkCopyrightHeaders.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/checkCopyrightHeaders.js b/scripts/checkCopyrightHeaders.js index 4d1b7e09962f..6407eb39b194 100755 --- a/scripts/checkCopyrightHeaders.js +++ b/scripts/checkCopyrightHeaders.js @@ -115,11 +115,12 @@ const INCLUDED_PATTERNS = [ /\.[^/]+$/, ]; -const COPYRIGHT_HEADER = - 'Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.'; -const LICENSE1 = - 'This source code is licensed under the MIT license found in the'; -const LICENSE2 = 'LICENSE file in the root directory of this source tree.'; +const COPYRIGHT_LICENSE = [ + ' * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.', + ' *', + ' * This source code is licensed under the MIT license found in the', + ' * LICENSE file in the root directory of this source tree.', +].join('\n'); function needsCopyrightHeader(file) { const contents = getFileContents(file); @@ -127,12 +128,7 @@ function needsCopyrightHeader(file) { // Match lines individually to avoid false positive for: // comment block versus lines // line ending LF versus CRLF - return ( - contents.trim().length > 0 && - (!contents.includes(COPYRIGHT_HEADER) || - !contents.includes(LICENSE1) || - !contents.includes(LICENSE2)) - ); + return contents.trim().length > 0 && !contents.includes(COPYRIGHT_LICENSE); } function check() { From 58513d2874f7d48d24b46187472b21fecaa0d3aa Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 12 Aug 2019 17:18:25 -0400 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00522ef3dbc5..462ef8d981c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - `[jest-core]` Add `getVersion` (moved from `jest-cli`) ([#8706](https://github.com/facebook/jest/pull/8706)) - `[docs]` Fix MockFunctions example that was using toContain instead of toContainEqual ([#8765](https://github.com/facebook/jest/pull/8765)) - `[*]` Make sure copyright header comment includes license ([#8783](https://github.com/facebook/jest/pull/8783)) +- `[*]` Check copyright and license as one joined substring ([#8815](https://github.com/facebook/jest/pull/8815)) - `[docs]` Fix WatchPlugins `jestHooks.shouldRunTestSuite` example that receives an object ([#8784](https://github.com/facebook/jest/pull/8784)) - `[*]` Enforce LF line endings ([#8809](https://github.com/facebook/jest/pull/8809)) From 7af814d3e607bf90c50ec12073e84cbf37d561d2 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Tue, 13 Aug 2019 10:35:55 -0400 Subject: [PATCH 3/3] Delete misleading comment --- scripts/checkCopyrightHeaders.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/checkCopyrightHeaders.js b/scripts/checkCopyrightHeaders.js index 6407eb39b194..af68d4c78723 100755 --- a/scripts/checkCopyrightHeaders.js +++ b/scripts/checkCopyrightHeaders.js @@ -124,10 +124,6 @@ const COPYRIGHT_LICENSE = [ function needsCopyrightHeader(file) { const contents = getFileContents(file); - - // Match lines individually to avoid false positive for: - // comment block versus lines - // line ending LF versus CRLF return contents.trim().length > 0 && !contents.includes(COPYRIGHT_LICENSE); }