0

WebUI: Disallow usages of obsolete Polymer() syntax via ESLint checks.

The class based "extends PolymerElement" syntax has been the preferred
way for a very long time and the vast majority of the codebase is
already using it.

Added a couple exceptions for a few CrOS folders that still use the old
syntax, and otherwise disallowing any new usages via ESLint's
no-restricted-imports rule.

All violations discovered with  the following command should have been
fixed or suppressed already.
git cl presubmit --files "*.js;*.ts"

Bug: 720034
Change-Id: I630dfbcfdbd1cab066e2faf145e6685ecb4693ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4412401
Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: Cole Horvitz <colehorvitz@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1128705}
This commit is contained in:
dpapad
2023-04-11 16:55:13 +00:00
committed by Chromium LUCI CQ
parent 6c8416e281
commit d6fe5df9f9
5 changed files with 42 additions and 0 deletions
.eslintrc.js
ash/webui
chrome/browser/resources
chromeos
nearby_internals
ui/file_manager/file_manager/foreground/elements

@ -27,6 +27,18 @@ module.exports = {
'no-extra-boolean-cast': 'error',
'no-extra-semi': 'error',
'no-new-wrappers': 'error',
'no-restricted-imports': ['error', {
'paths': [{
'name': 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js',
'importNames': ['Polymer'],
'message': 'Use PolymerElement instead.',
},
{
'name': '//resources/polymer/v3_0/polymer/polymer_bundled.min.js',
'importNames': ['Polymer'],
'message': 'Use PolymerElement instead.',
}],
}],
'no-restricted-properties': [
'error',
{

@ -6,5 +6,9 @@ module.exports = {
'rules' : {
'comma-dangle' : ['error', 'always-multiline'],
'no-console' : 'off',
// Turn off since there are too many imports of 'Polymer'. Remove if/when
// everything under this folder is migrated to PolymerElement.
'no-restricted-imports' : 'off',
},
};

@ -5,5 +5,9 @@
module.exports = {
'rules' : {
'eqeqeq' : 'off',
// Turn off since there are too many imports of 'Polymer'. Remove if/when
// everything under this folder is migrated to PolymerElement.
'no-restricted-imports': 'off',
},
};

@ -0,0 +1,11 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'rules' : {
// Remove if/when everything under this folder is migrated to
// PolymerElement.
'no-restricted-imports': 'off',
},
};

@ -0,0 +1,11 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'rules' : {
// Turn off since there are many imports of 'Polymer'. Remove if/when
// everything under this folder is migrated to PolymerElement.
'no-restricted-imports': 'off',
},
};