From 5bb7528e13f05d0fcee9b75aa1dfd670848c81d4 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 16 Feb 2021 10:35:43 +0000 Subject: [PATCH] Update check_license_header rule with new year It was inserting comments with 2020 in. I've updated it to figure out the current year. This theoretically could cause problems if people are either side of a year on New Years eve, but I'm hoping people are busy not working then :D Bug: none Change-Id: I9f6cc9329189d89e6994cc0963fa70617cb446c3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2696660 Reviewed-by: Tim van der Lippe Commit-Queue: Jack Franklin --- scripts/eslint_rules/lib/check_license_header.js | 6 ++++-- .../eslint_rules/tests/check_license_header_test.js | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/eslint_rules/lib/check_license_header.js b/scripts/eslint_rules/lib/check_license_header.js index 50140c27eb..3041200f9c 100644 --- a/scripts/eslint_rules/lib/check_license_header.js +++ b/scripts/eslint_rules/lib/check_license_header.js @@ -12,8 +12,9 @@ const path = require('path'); const FRONT_END_FOLDER = path.join(__filename, '..', '..', '..', '..', 'front_end'); +const CURRENT_YEAR = new Date().getFullYear(); const LINE_LICENSE_HEADER = [ - 'Copyright 2020 The Chromium Authors. All rights reserved.', + `Copyright ${CURRENT_YEAR} The Chromium Authors. All rights reserved.`, 'Use of this source code is governed by a BSD-style license that can be', 'found in the LICENSE file.', ]; @@ -48,7 +49,8 @@ const BLOCK_LICENSE_HEADER = [ 'OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.', ]; -const LINE_REGEXES = LINE_LICENSE_HEADER.map(line => new RegExp('[ ]?' + line.replace('2020', '(\\(c\\) )?\\d{4}'))); +const LINE_REGEXES = + LINE_LICENSE_HEADER.map(line => new RegExp('[ ]?' + line.replace(CURRENT_YEAR, '(\\(c\\) )?\\d{4}'))); const BLOCK_REGEX = new RegExp('[\\s\\\\n\\*]*' + BLOCK_LICENSE_HEADER.join('[\\s\\\\n\\*]*'), 'm'); const LICENSE_HEADER_ADDITION = LINE_LICENSE_HEADER.map(line => `// ${line}`).join('\n') + '\n\n'; diff --git a/scripts/eslint_rules/tests/check_license_header_test.js b/scripts/eslint_rules/tests/check_license_header_test.js index 2b11cdcfbe..ad1b171929 100644 --- a/scripts/eslint_rules/tests/check_license_header_test.js +++ b/scripts/eslint_rules/tests/check_license_header_test.js @@ -104,7 +104,7 @@ import * as Common from '../common/common.js'; code: 'import * as Action from \'./Action.js\';', filename: 'front_end/ui/ui.js', errors: [{message: 'Missing license header'}], - output: `// Copyright 2020 The Chromium Authors. All rights reserved. + output: `// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -119,7 +119,7 @@ import * as Action from './Action.js'; filename: 'front_end/ui/ui.js', errors: [{message: 'Incorrect line license header'}], output: ` -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -135,7 +135,7 @@ import * as Action from './Action.js'; (async function() {})();`, filename: 'test/webtests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test.js', errors: [{message: 'Incorrect line license header'}], - output: `// Copyright 2020 The Chromium Authors. All rights reserved. + output: `// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -156,7 +156,7 @@ import * as Action from './Action.js'; filename: 'front_end/ui/ui.js', errors: [{message: 'Incorrect line license header'}], output: ` -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -179,7 +179,7 @@ import * as Action from './Action.js'; filename: 'front_end/ui/ui.js', errors: [{message: 'Incorrect block license header'}], output: ` -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -213,7 +213,7 @@ interface String { filename: 'front_end/legacy/legacy-defs.d.ts', errors: [{message: 'Missing license header'}], output: ` -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.