Commit ebc2c0d2 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Merge .eslintrc.js in core/script/layered_api/ subdirectories into one

elements/toast/.eslintrc.js and kv-storage/.eslintrc.js were identical,
and elements/virtual-scroller/.eslintrc.js had some differences.  The
following describes differences between them and decision for them.

* virtual-scroller had '2' for no-magic-numbers exceptions.
 We keep the '2' exception.

* virtual-scroller enabled max-len.
 We enable max-len.
 max-len is helpful because clang-format doesn't support *.mjs extension
 for now.

* virtual-scroller had no no-lonely-if and no no-else-return.
 We drop them.
 Following these rules is sometimes harmful for code consistency.

Change-Id: Icf3118e4d504248a55a284a763f7392c59793769
Bug: 976576
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1727447
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarDomenic Denicola <domenic@chromium.org>
Reviewed-by: default avatarFergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683107}
parent 9daf9f18
...@@ -73,7 +73,6 @@ module.exports = { ...@@ -73,7 +73,6 @@ module.exports = {
'no-caller': 'error', 'no-caller': 'error',
'no-case-declarations': 'error', 'no-case-declarations': 'error',
'no-div-regex': 'off', 'no-div-regex': 'off',
'no-else-return': 'error',
'no-empty-function': 'off', 'no-empty-function': 'off',
'no-empty-pattern': 'error', 'no-empty-pattern': 'error',
'no-eq-null': 'error', 'no-eq-null': 'error',
...@@ -94,7 +93,7 @@ module.exports = { ...@@ -94,7 +93,7 @@ module.exports = {
'no-labels': ['error', {allowLoop: true}], 'no-labels': ['error', {allowLoop: true}],
'no-lone-blocks': 'error', 'no-lone-blocks': 'error',
'no-loop-func': 'error', 'no-loop-func': 'error',
'no-magic-numbers': ['error', {ignore: [0, 1]}], 'no-magic-numbers': ['error', {ignore: [0, 1, 2]}],
'no-multi-spaces': ['error', {ignoreEOLComments: true}], 'no-multi-spaces': ['error', {ignoreEOLComments: true}],
'no-multi-str': 'error', 'no-multi-str': 'error',
'no-new': 'error', 'no-new': 'error',
...@@ -204,7 +203,9 @@ module.exports = { ...@@ -204,7 +203,9 @@ module.exports = {
'linebreak-style': ['error', 'unix'], 'linebreak-style': ['error', 'unix'],
'lines-around-comment': 'off', 'lines-around-comment': 'off',
'max-depth': 'off', 'max-depth': 'off',
'max-len': 'off', 'max-len': ['error', {
tabWidth: 2,
ignorePattern: "(^import |// eslint-disable-line |https?://)"}],
'max-lines': 'off', 'max-lines': 'off',
'max-nested-callbacks': 'off', 'max-nested-callbacks': 'off',
'max-params': 'off', 'max-params': 'off',
...@@ -218,7 +219,6 @@ module.exports = { ...@@ -218,7 +219,6 @@ module.exports = {
'no-bitwise': 'off', 'no-bitwise': 'off',
'no-continue': 'off', 'no-continue': 'off',
'no-inline-comments': 'off', 'no-inline-comments': 'off',
'no-lonely-if': 'error',
'no-mixed-operators': [ 'no-mixed-operators': [
'error', 'error',
{ {
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
* this argument is omitted. * this argument is omitted.
*/ */
export function installBool(proto, attrName, propName = attrName) { export function installBool(proto, attrName, propName = attrName) {
let getter = function() { function getter() {
return this.hasAttribute(attrName); return this.hasAttribute(attrName);
}; }
let setter = function(value) { function setter(value) {
this.toggleAttribute(attrName, Boolean(value)); this.toggleAttribute(attrName, Boolean(value));
}; }
Object.defineProperty( Object.defineProperty(
getter, 'name', getter, 'name',
{configurable: true, enumerable: false, value: 'get ' + propName}); {configurable: true, enumerable: false, value: 'get ' + propName});
...@@ -44,13 +44,13 @@ export function installBool(proto, attrName, propName = attrName) { ...@@ -44,13 +44,13 @@ export function installBool(proto, attrName, propName = attrName) {
* this argument is omitted. * this argument is omitted.
*/ */
export function installString(proto, attrName, propName = attrName) { export function installString(proto, attrName, propName = attrName) {
let getter = function() { function getter() {
let value = this.getAttribute(attrName); const value = this.getAttribute(attrName);
return value === null ? '' : value; return value === null ? '' : value;
}; }
let setter = function(value) { function setter(value) {
this.setAttribute(attrName, value); this.setAttribute(attrName, value);
}; }
Object.defineProperty( Object.defineProperty(
getter, 'name', getter, 'name',
{configurable: true, enumerable: false, value: 'get ' + propName}); {configurable: true, enumerable: false, value: 'get ' + propName});
......
...@@ -37,36 +37,36 @@ function installGetter(proto, propName, getter) { ...@@ -37,36 +37,36 @@ function installGetter(proto, propName, getter) {
export function installPropertiesAndFunctions(proto, internals) { export function installPropertiesAndFunctions(proto, internals) {
reflection.installBool(proto, 'disabled'); reflection.installBool(proto, 'disabled');
reflection.installString(proto, 'name'); reflection.installString(proto, 'name');
installGetter(proto, 'type', function() { installGetter(proto, 'type', function () {
if (!(this instanceof proto.constructor)) { if (!(this instanceof proto.constructor)) {
throw TypeError( throw new TypeError(
'The context object is not an instance of ' + proto.contructor.name); 'The context object is not an instance of ' + proto.contructor.name);
} }
return this.localName; return this.localName;
}); });
installGetter(proto, 'form', function() { installGetter(proto, 'form', function () {
return this[internals].form; return this[internals].form;
}); });
installGetter(proto, 'willValidate', function() { installGetter(proto, 'willValidate', function () {
return this[internals].willValidate; return this[internals].willValidate;
}); });
installGetter(proto, 'validity', function() { installGetter(proto, 'validity', function () {
return this[internals].validity; return this[internals].validity;
}); });
installGetter(proto, 'validationMessage', function() { installGetter(proto, 'validationMessage', function () {
return this[internals].validationMessage; return this[internals].validationMessage;
}); });
installGetter(proto, 'labels', function() { installGetter(proto, 'labels', function () {
return this[internals].labels; return this[internals].labels;
}); });
proto.checkValidity = function() { proto.checkValidity = function () {
return this[internals].checkValidity(); return this[internals].checkValidity();
}; };
proto.reportValidity = function() { proto.reportValidity = function () {
return this[internals].reportValidity(); return this[internals].reportValidity();
}; };
proto.setCustomValidity = function(error) { proto.setCustomValidity = function (error) {
if (error === undefined) { if (error === undefined) {
throw new TypeError('Too few arguments'); throw new TypeError('Too few arguments');
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import * as face from './face_utils.mjs'; import * as face from './face_utils.mjs';
import * as reflection from '../internal/reflection.mjs'; import * as reflection from '../internal/reflection.mjs';
import { SwitchTrack } from './track.mjs'; import {SwitchTrack} from './track.mjs';
import * as style from './style.mjs'; import * as style from './style.mjs';
const generateStyleSheet = style.styleSheetFactory(); const generateStyleSheet = style.styleSheetFactory();
...@@ -14,10 +14,10 @@ const STATE_ATTR = 'on'; ...@@ -14,10 +14,10 @@ const STATE_ATTR = 'on';
// Private property symbols // Private property symbols
// TODO(tkent): Use private fields. // TODO(tkent): Use private fields.
const _internals = Symbol(); const _internals = Symbol('an ElementInternals field');
const _track = Symbol(); const _track = Symbol('a track element field');
const _rippleElement = Symbol(); const _rippleElement = Symbol('a ripple element field');
const _containerElement = Symbol(); const _containerElement = Symbol('A container element field');
export class StdSwitchElement extends HTMLElement { export class StdSwitchElement extends HTMLElement {
// TODO(tkent): The following should be |static fooBar = value;| // TODO(tkent): The following should be |static fooBar = value;|
...@@ -43,7 +43,7 @@ export class StdSwitchElement extends HTMLElement { ...@@ -43,7 +43,7 @@ export class StdSwitchElement extends HTMLElement {
} }
attributeChangedCallback(attrName, oldValue, newValue) { attributeChangedCallback(attrName, oldValue, newValue) {
if (attrName == STATE_ATTR) { if (attrName === STATE_ATTR) {
this[_track].value = newValue !== null; this[_track].value = newValue !== null;
// TODO(tkent): We should not add aria-checked attribute. // TODO(tkent): We should not add aria-checked attribute.
// https://github.com/WICG/aom/issues/127 // https://github.com/WICG/aom/issues/127
...@@ -67,8 +67,8 @@ export class StdSwitchElement extends HTMLElement { ...@@ -67,8 +67,8 @@ export class StdSwitchElement extends HTMLElement {
// TODO(tkent): Make this private. // TODO(tkent): Make this private.
_initializeDOM() { _initializeDOM() {
let factory = this.ownerDocument; const factory = this.ownerDocument;
let root = this.attachShadow({mode: 'closed'}); const root = this.attachShadow({mode: 'closed'});
this[_containerElement] = factory.createElement('span'); this[_containerElement] = factory.createElement('span');
this[_containerElement].id = 'container'; this[_containerElement].id = 'container';
// Shadow elements should be invisible for a11y technologies. // Shadow elements should be invisible for a11y technologies.
...@@ -79,19 +79,21 @@ export class StdSwitchElement extends HTMLElement { ...@@ -79,19 +79,21 @@ export class StdSwitchElement extends HTMLElement {
this[_containerElement].appendChild(this[_track].element); this[_containerElement].appendChild(this[_track].element);
this[_track].value = this.on; this[_track].value = this.on;
let thumbElement = this[_containerElement].appendChild(factory.createElement('span')); const thumbElement =
this[_containerElement].appendChild(factory.createElement('span'));
thumbElement.id = 'thumb'; thumbElement.id = 'thumb';
thumbElement.part.add('thumb'); thumbElement.part.add('thumb');
this[_rippleElement] = thumbElement.appendChild(factory.createElement('span')); this[_rippleElement] =
thumbElement.appendChild(factory.createElement('span'));
this[_rippleElement].id = 'ripple'; this[_rippleElement].id = 'ripple';
root.adoptedStyleSheets = [generateStyleSheet()]; root.adoptedStyleSheets = [generateStyleSheet()];
} }
// TODO(tkent): Make this private. // TODO(tkent): Make this private.
_onClick(event) { _onClick() {
for (let element of this[_containerElement].querySelectorAll('*')) { for (const element of this[_containerElement].querySelectorAll('*')) {
style.markTransition(element); style.markTransition(element);
} }
this.on = !this.on; this.on = !this.on;
...@@ -101,7 +103,7 @@ export class StdSwitchElement extends HTMLElement { ...@@ -101,7 +103,7 @@ export class StdSwitchElement extends HTMLElement {
// TODO(tkent): Make this private. // TODO(tkent): Make this private.
_onKeyPress(event) { _onKeyPress(event) {
if (event.code == 'Space') { if (event.code === 'Space') {
// Do not scroll the page. // Do not scroll the page.
event.preventDefault(); event.preventDefault();
this._onClick(event); this._onClick(event);
...@@ -120,7 +122,7 @@ Object.defineProperty(StdSwitchElement.prototype, Symbol.toStringTag, { ...@@ -120,7 +122,7 @@ Object.defineProperty(StdSwitchElement.prototype, Symbol.toStringTag, {
configurable: true, configurable: true,
enumerable: false, enumerable: false,
value: 'StdSwitchElement', value: 'StdSwitchElement',
writable: false writable: false,
}); });
customElements.define('std-switch', StdSwitchElement); customElements.define('std-switch', StdSwitchElement);
......
...@@ -164,20 +164,21 @@ function setupTransitionCounter(element) { ...@@ -164,20 +164,21 @@ function setupTransitionCounter(element) {
++element.runningTransitions; ++element.runningTransitions;
} }
}); });
let handleEndOrCancel = e => { function handleEndOrCancel(e) {
// Need to check runningTransitions>0 due to superfluous transitioncancel // Need to check runningTransitions>0 due to superfluous transitioncancel
// events; crbug.com/979556. // events; crbug.com/979556.
if (e.target === element && element.runningTransitions > 0) { if (e.target === element && element.runningTransitions > 0) {
--element.runningTransitions; --element.runningTransitions;
} }
}; }
element.addEventListener('transitionend', handleEndOrCancel); element.addEventListener('transitionend', handleEndOrCancel);
element.addEventListener('transitioncancel', handleEndOrCancel); element.addEventListener('transitioncancel', handleEndOrCancel);
} }
/** /**
* Add '$part-transitioning' part to the element, and remove it on 'transitionend' * Add '$part-transitioning' part to the element, and remove it on
* event or remove it immediately if the element has no transitions. * 'transitionend' event or remove it immediately if the element has no
* transitions.
* *
* TODO(tkent): We should apply custom state. * TODO(tkent): We should apply custom state.
* *
...@@ -211,14 +212,14 @@ export function markTransition(element) { ...@@ -211,14 +212,14 @@ export function markTransition(element) {
// If the element has a transition, it must start on the rendering just // If the element has a transition, it must start on the rendering just
// after this rAF callback. So we check runningTransitions in the next // after this rAF callback. So we check runningTransitions in the next
// frame. // frame.
const removeIfNoTransitions = () => { function removeIfNoTransitions() {
// No transitions started, or all transitions were completed. // No transitions started, or all transitions were completed.
if (element.runningTransitions === 0) { if (element.runningTransitions === 0) {
element.part.remove(partName); element.part.remove(partName);
} else { } else {
window.requestAnimationFrame(removeIfNoTransitions); window.requestAnimationFrame(removeIfNoTransitions);
} }
}; }
window.requestAnimationFrame(removeIfNoTransitions); window.requestAnimationFrame(removeIfNoTransitions);
}); });
} }
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
// Private property symbols // Private property symbols
// TODO(tkent): Use private fields. // TODO(tkent): Use private fields.
const _value = Symbol(); const _value = Symbol('A boolean track value field');
const _trackElement = Symbol(); const _trackElement = Symbol('A track element field');
const _fillElement = Symbol(); const _fillElement = Symbol('A trackFill element field');
const _slotElement = Symbol(); const _slotElement = Symbol('A slot element field');
export class SwitchTrack { export class SwitchTrack {
/** /**
* @param {!Document} factory A factory for elements created for this track. * @param {!Document} factory A factory for elements created for this track.
*/ */
...@@ -30,13 +29,13 @@ export class SwitchTrack { ...@@ -30,13 +29,13 @@ export class SwitchTrack {
* @param {Boolean} newValue * @param {Boolean} newValue
*/ */
set value(newValue) { set value(newValue) {
let oldValue = this[_value]; const oldValue = this[_value];
this[_value] = Boolean(newValue); this[_value] = Boolean(newValue);
let bar = this[_fillElement]; const bar = this[_fillElement];
if (bar) { if (bar) {
bar.style.inlineSize = this[_value] ? '100%' : '0%'; bar.style.inlineSize = this[_value] ? '100%' : '0%';
if (oldValue != this[_value]) { if (oldValue !== this[_value]) {
this._addSlot(); this._addSlot();
} }
} }
......
...@@ -52,8 +52,8 @@ function styleSheetFactory() { ...@@ -52,8 +52,8 @@ function styleSheetFactory() {
border-color: red; border-color: red;
} }
`); `);
// TODO(jacksteinberg): use offset-block-end: / offset-inline-end: over bottom: / right: // TODO(jacksteinberg): use offset-block-end: / offset-inline-end: over
// when implemented https://bugs.chromium.org/p/chromium/issues/detail?id=538475 // bottom: / right: when implemented http://crbug.com/538475.
} }
return stylesheet; return stylesheet;
}; };
...@@ -108,7 +108,8 @@ export class StdToastElement extends HTMLElement { ...@@ -108,7 +108,8 @@ export class StdToastElement extends HTMLElement {
if (!this.hasAttribute('role')) { if (!this.hasAttribute('role')) {
this.setAttribute('role', 'status'); this.setAttribute('role', 'status');
} }
// TODO(jacksteinberg): use https://github.com/whatwg/html/pull/4658 when implemented // TODO(jacksteinberg): use https://github.com/whatwg/html/pull/4658
// when implemented
} }
get action() { get action() {
...@@ -172,7 +173,8 @@ export class StdToastElement extends HTMLElement { ...@@ -172,7 +173,8 @@ export class StdToastElement extends HTMLElement {
show({duration = DEFAULT_DURATION} = {}) { show({duration = DEFAULT_DURATION} = {}) {
if (duration <= 0) { if (duration <= 0) {
throw new RangeError(`Invalid Argument: duration must be greater than 0 [${duration} given]`); throw new RangeError(`Invalid Argument: duration must be greater ` +
`than 0 [${duration} given]`);
} }
this.setAttribute('open', ''); this.setAttribute('open', '');
......
// Copyright 2019 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.
module.exports = {
root: true,
env: {
es6: true,
browser: true
},
'parser': 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2019
},
rules: {
'for-direction': 'error',
'getter-return': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'except-parens'],
'no-console': 'error',
'no-constant-condition': ['error', {checkLoops: false}],
'no-control-regex': 'error',
'no-debugger': 'error',
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': [
'error',
'all',
{
conditionalAssign: false,
nestedBinaryExpressions: false,
returnAssign: false
}
],
'no-extra-semi': 'error',
'no-func-assign': 'error',
'no-inner-declarations': 'off',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-misleading-character-class': 'error',
'no-obj-calls': 'error',
'no-prototype-builtins': 'error',
'no-regex-spaces': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'off',
'no-unsafe-negation': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
'accessor-pairs': 'error',
'array-callback-return': 'error',
'block-scoped-var': 'off',
'class-methods-use-this': 'off',
'complexity': 'off',
'consistent-return': 'error',
'curly': ['error', 'all'],
'default-case': 'off',
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'eqeqeq': 'error',
'guard-for-in': 'off',
'no-alert': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-div-regex': 'off',
'no-empty-function': 'off',
'no-empty-pattern': 'error',
'no-eq-null': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-global-assign': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-iterator': 'error',
'no-labels': ['error', {allowLoop: true}],
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-magic-numbers': ['error', {ignore: [0, 1, 2]}],
'no-multi-spaces': ['error', {ignoreEOLComments: true}],
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'off',
'no-process-env': 'error',
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-properties': 'off',
'no-return-assign': ['error', 'except-parens'],
'no-return-await': 'error',
'no-script-url': 'off',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'error',
'no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': 'off',
'no-with': 'error',
'prefer-promise-reject-errors': 'error',
'radix': ['error', 'as-needed'],
'require-await': 'off',
'vars-on-top': 'off',
'wrap-iife': ['error', 'outside'],
'yoda': ['error', 'never'],
'strict': ['error', 'global'],
'init-declarations': 'off',
'no-delete-var': 'error',
'no-label-var': 'error',
'no-restricted-globals': 'off',
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-undefined': 'off',
'no-unused-vars': 'error',
'no-use-before-define': ['error', 'nofunc'],
'callback-return': 'off',
'global-require': 'error',
'handle-callback-err': 'error',
'no-buffer-constructor': 'error',
'no-mixed-requires': ['error', true],
'no-new-require': 'error',
'no-path-concat': 'error',
'no-process-exit': 'error',
'no-restricted-modules': 'off',
'no-sync': 'off',
'array-bracket-newline': ['error', {multiline: true}],
'array-bracket-spacing': ['error', 'never'],
'array-element-newline': 'off',
'block-spacing': ['error', 'always'],
'brace-style': [
'error',
'1tbs',
{allowSingleLine: false}
],
camelcase: ['error', {properties: 'always'}],
'capitalized-comments': 'off',
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': [
'error',
{
before: false,
after: true
}
],
'comma-style': ['error', 'last'],
'computed-property-spacing': ['error', 'never'],
'consistent-this': 'off',
'eol-last': 'error',
'func-call-spacing': ['error', 'never'],
'func-name-matching': 'error',
'func-names': 'off',
'func-style': ['error', 'declaration'],
'function-paren-newline': 'off',
'id-blacklist': 'off',
'id-length': 'off',
'id-match': 'off',
indent: 'off', // not really compatible with clang-format
'jsx-quotes': 'off',
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
mode: 'strict'
}
],
'keyword-spacing': [
'error',
{
before: true,
after: true
}
],
'line-comment-position': 'off',
'linebreak-style': ['error', 'unix'],
'lines-around-comment': 'off',
'max-depth': 'off',
'max-len': ['error', {
tabWidth: 2,
ignorePattern: "(^import |// eslint-disable-line )"}],
'max-lines': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements': 'off',
'max-statements-per-line': ['error', {max: 1}],
'multiline-ternary': ['error', 'always-multiline'],
'new-cap': 'error',
'new-parens': 'error',
'newline-per-chained-call': 'off',
'no-array-constructor': 'error',
'no-bitwise': 'off',
'no-continue': 'off',
'no-inline-comments': 'off',
'no-mixed-operators': [
'error',
{
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof']
]
}
],
'no-mixed-spaces-and-tabs': 'error',
'no-multi-assign': 'off',
'no-multiple-empty-lines': 'error',
'no-negated-condition': 'off',
'no-nested-ternary': 'error',
'no-new-object': 'error',
'no-plusplus': 'off',
'no-restricted-syntax': 'off',
'no-tabs': 'error',
'no-ternary': 'off',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'error',
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': 'error',
'object-curly-newline': ['error', {consistent: true}],
'object-curly-spacing': ['error', 'never'],
'object-property-newline': 'off',
'one-var': ['error', 'never'],
'one-var-declaration-per-line': ['error', 'initializations'],
'operator-assignment': ['error', 'always'],
'operator-linebreak': ['error', 'after'],
'padded-blocks': ['error', 'never'],
'padding-line-between-statements': 'off',
'quote-props': ['error', 'as-needed'],
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: ['error', 'always'],
'semi-spacing': 'error',
'semi-style': 'error',
'sort-keys': 'off',
'sort-vars': 'off',
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never'
}
],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': [
'error',
{
words: true,
nonwords: false
}
],
'spaced-comment': ['error', 'always'],
'switch-colon-spacing': 'error',
'template-tag-spacing': 'error',
'unicode-bom': 'error',
'wrap-regex': 'off',
'arrow-body-style': 'off',
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': 'error',
'constructor-super': 'error',
'generator-star-spacing': ['error', 'neither'],
'no-class-assign': 'error',
'no-confusing-arrow': 'off',
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-duplicate-imports': 'error',
'no-new-symbol': 'error',
'no-restricted-imports': 'off',
'no-this-before-super': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': ['error', {ignoreReadBeforeAssign: true}],
'prefer-destructuring': [
'error',
{
VariableDeclarator: {
array: false,
object: true
},
AssignmentExpression: {
array: false,
object: false
}
},
{
enforceForRenamedProperties: false
}
],
'prefer-numeric-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'off',
'require-yield': 'error',
'rest-spread-spacing': 'error',
'sort-imports': 'off',
'symbol-description': 'error',
'template-curly-spacing': ['error', 'never'],
'yield-star-spacing': ['error', 'after']
}
};
// Copyright 2019 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.
module.exports = {
root: true,
env: {
es6: true,
browser: true
},
'parser': 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2019
},
rules: {
'for-direction': 'error',
'getter-return': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'except-parens'],
'no-console': 'error',
'no-constant-condition': ['error', {checkLoops: false}],
'no-control-regex': 'error',
'no-debugger': 'error',
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': [
'error',
'all',
{
conditionalAssign: false,
nestedBinaryExpressions: false,
returnAssign: false
}
],
'no-extra-semi': 'error',
'no-func-assign': 'error',
'no-inner-declarations': 'off',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-misleading-character-class': 'error',
'no-obj-calls': 'error',
'no-prototype-builtins': 'error',
'no-regex-spaces': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'off',
'no-unsafe-negation': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
'accessor-pairs': 'error',
'array-callback-return': 'error',
'block-scoped-var': 'off',
'class-methods-use-this': 'off',
'complexity': 'off',
'consistent-return': 'error',
'curly': ['error', 'all'],
'default-case': 'off',
'dot-location': ['error', 'property'],
'dot-notation': 'error',
'eqeqeq': 'error',
'guard-for-in': 'off',
'no-alert': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-div-regex': 'off',
'no-else-return': 'error',
'no-empty-function': 'off',
'no-empty-pattern': 'error',
'no-eq-null': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-global-assign': 'error',
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
// no-invalid-this doesn't work well for private fields.
// https://github.com/babel/eslint-plugin-babel/issues/182
// 'no-invalid-this': 'error',
'no-iterator': 'error',
'no-labels': ['error', {allowLoop: true}],
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-magic-numbers': ['error', {ignore: [0, 1]}],
'no-multi-spaces': ['error', {ignoreEOLComments: true}],
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'off',
'no-process-env': 'error',
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-properties': 'off',
'no-return-assign': ['error', 'except-parens'],
'no-return-await': 'error',
'no-script-url': 'off',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'error',
'no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': 'off',
'no-with': 'error',
'prefer-promise-reject-errors': 'error',
'radix': ['error', 'as-needed'],
'require-await': 'off',
'vars-on-top': 'off',
'wrap-iife': ['error', 'outside'],
'yoda': ['error', 'never'],
'strict': ['error', 'global'],
'init-declarations': 'off',
'no-delete-var': 'error',
'no-label-var': 'error',
'no-restricted-globals': 'off',
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-undefined': 'off',
'no-unused-vars': 'error',
'no-use-before-define': ['error', 'nofunc'],
'callback-return': 'off',
'global-require': 'error',
'handle-callback-err': 'error',
'no-buffer-constructor': 'error',
'no-mixed-requires': ['error', true],
'no-new-require': 'error',
'no-path-concat': 'error',
'no-process-exit': 'error',
'no-restricted-modules': 'off',
'no-sync': 'off',
'array-bracket-newline': ['error', {multiline: true}],
'array-bracket-spacing': ['error', 'never'],
'array-element-newline': 'off',
'block-spacing': ['error', 'always'],
'brace-style': [
'error',
'1tbs',
{allowSingleLine: false}
],
camelcase: ['error', {properties: 'always'}],
'capitalized-comments': 'off',
'comma-dangle': ['error', 'always-multiline'],
'comma-spacing': [
'error',
{
before: false,
after: true
}
],
'comma-style': ['error', 'last'],
'computed-property-spacing': ['error', 'never'],
'consistent-this': 'off',
'eol-last': 'error',
'func-call-spacing': ['error', 'never'],
'func-name-matching': 'error',
'func-names': 'off',
'func-style': ['error', 'declaration'],
'function-paren-newline': 'off',
'id-blacklist': 'off',
'id-length': 'off',
'id-match': 'off',
indent: 'off', // not really compatible with clang-format
'jsx-quotes': 'off',
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true,
mode: 'strict'
}
],
'keyword-spacing': [
'error',
{
before: true,
after: true
}
],
'line-comment-position': 'off',
'linebreak-style': ['error', 'unix'],
'lines-around-comment': 'off',
'max-depth': 'off',
'max-len': 'off',
'max-lines': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements': 'off',
'max-statements-per-line': ['error', {max: 1}],
'multiline-ternary': ['error', 'always-multiline'],
'new-cap': 'error',
'new-parens': 'error',
'newline-per-chained-call': 'off',
'no-array-constructor': 'error',
'no-bitwise': 'off',
'no-continue': 'off',
'no-inline-comments': 'off',
'no-lonely-if': 'error',
'no-mixed-operators': [
'error',
{
groups: [
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof']
]
}
],
'no-mixed-spaces-and-tabs': 'error',
'no-multi-assign': 'off',
'no-multiple-empty-lines': 'error',
'no-negated-condition': 'off',
'no-nested-ternary': 'error',
'no-new-object': 'error',
'no-plusplus': 'off',
'no-restricted-syntax': 'off',
'no-tabs': 'error',
'no-ternary': 'off',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'error',
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': 'error',
'object-curly-newline': ['error', {consistent: true}],
'object-curly-spacing': ['error', 'never'],
'object-property-newline': 'off',
'one-var': ['error', 'never'],
'one-var-declaration-per-line': ['error', 'initializations'],
'operator-assignment': ['error', 'always'],
'operator-linebreak': ['error', 'after'],
'padded-blocks': ['error', 'never'],
'padding-line-between-statements': 'off',
'quote-props': ['error', 'as-needed'],
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: ['error', 'always'],
'semi-spacing': 'error',
'semi-style': 'error',
'sort-keys': 'off',
'sort-vars': 'off',
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never'
}
],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': [
'error',
{
words: true,
nonwords: false
}
],
'spaced-comment': ['error', 'always'],
'switch-colon-spacing': 'error',
'template-tag-spacing': 'error',
'unicode-bom': 'error',
'wrap-regex': 'off',
'arrow-body-style': 'off',
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': 'error',
'constructor-super': 'error',
'generator-star-spacing': ['error', 'neither'],
'no-class-assign': 'error',
'no-confusing-arrow': 'off',
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-duplicate-imports': 'error',
'no-new-symbol': 'error',
'no-restricted-imports': 'off',
'no-this-before-super': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': ['error', {ignoreReadBeforeAssign: true}],
'prefer-destructuring': [
'error',
{
VariableDeclarator: {
array: false,
object: true
},
AssignmentExpression: {
array: false,
object: false
}
},
{
enforceForRenamedProperties: false
}
],
'prefer-numeric-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'off',
'require-yield': 'error',
'rest-spread-spacing': 'error',
'sort-imports': 'off',
'symbol-description': 'error',
'template-curly-spacing': ['error', 'never'],
'yield-star-spacing': ['error', 'after']
}
};
...@@ -73,12 +73,13 @@ export class StorageArea { ...@@ -73,12 +73,13 @@ export class StorageArea {
async clear() { async clear() {
if (!this.#databasePromise) { if (!this.#databasePromise) {
// Don't try to delete, and clear the promise, while we're opening the database; wait for that // Don't try to delete, and clear the promise, while we're opening the
// first. // database; wait for that first.
try { try {
await this.#databasePromise; await this.#databasePromise;
} catch { } catch {
// If the database failed to initialize, then that's fine, we'll still try to delete it. // If the database failed to initialize, then that's fine, we'll still
// try to delete it.
} }
this.#databasePromise = undefined; this.#databasePromise = undefined;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment