chore: update to latest eslint

This commit is contained in:
qa46hx 2021-02-23 15:06:28 +01:00 committed by Joren Broekema
parent 889a9845bc
commit 8fdfe37a3c
22 changed files with 429 additions and 427 deletions

View file

@ -17,6 +17,9 @@ module.exports = {
'**/*.config.js', '**/*.config.js',
], ],
rules: { rules: {
'lit/binding-positions': 'off',
'lit/no-invalid-html': 'off',
'lit/no-useless-template-literals': 'off',
'no-console': 'off', 'no-console': 'off',
'no-unused-expressions': 'off', 'no-unused-expressions': 'off',
'class-methods-use-this': 'off', 'class-methods-use-this': 'off',

View file

@ -47,7 +47,7 @@
"@mdjs/core": "^0.3.1", "@mdjs/core": "^0.3.1",
"@open-wc/building-rollup": "^1.2.1", "@open-wc/building-rollup": "^1.2.1",
"@open-wc/demoing-storybook": "^2.0.2", "@open-wc/demoing-storybook": "^2.0.2",
"@open-wc/eslint-config": "^1.0.0", "@open-wc/eslint-config": "^4.2.0",
"@open-wc/testing": "^2.5.18", "@open-wc/testing": "^2.5.18",
"@open-wc/testing-helpers": "^1.0.0", "@open-wc/testing-helpers": "^1.0.0",
"@storybook/addon-a11y": "^5.3.21", "@storybook/addon-a11y": "^5.3.21",
@ -60,15 +60,19 @@
"@webcomponents/webcomponentsjs": "^2.4.4", "@webcomponents/webcomponentsjs": "^2.4.4",
"babel-eslint": "^8.2.6", "babel-eslint": "^8.2.6",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"bundlesize": "^0.17.1", "bundlesize": "^1.0.0-beta.2",
"chai": "^4.2.0", "chai": "^4.2.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"concurrently": "^5.2.0", "concurrently": "^5.2.0",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"eclint": "^2.1.0", "eclint": "^2.1.0",
"es6-promisify": "^6.1.1", "es6-promisify": "^6.1.1",
"eslint": "^6.1.0", "eslint": "^7.20.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^8.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-lit": "^1.3.0",
"eslint-plugin-lit-a11y": "^1.0.1",
"eslint-plugin-wc": "^1.2.0",
"husky": "^1.3.1", "husky": "^1.3.1",
"lint-staged": "^10.0.0", "lint-staged": "^10.0.0",
"looks-same": "^7.2.3", "looks-same": "^7.2.3",

View file

@ -7,7 +7,8 @@ export class MyCounter extends LitElement {
}; };
} }
static styles = css` static get styles() {
return css`
:host { :host {
display: block; display: block;
width: 220px; width: 220px;
@ -38,6 +39,7 @@ export class MyCounter extends LitElement {
text-align: center; text-align: center;
} }
`; `;
}
constructor() { constructor() {
super(); super();

View file

@ -89,7 +89,7 @@ class PBoard extends DecorateMixin(LitElement) {
type="checkbox" type="checkbox"
name="references" name="references"
.checked=${colName === 'lion-based-ui'} .checked=${colName === 'lion-based-ui'}
value="${refName}" .value="${refName}"
/>${refName}</label />${refName}</label
> >
`, `,
@ -130,7 +130,7 @@ class PBoard extends DecorateMixin(LitElement) {
type="checkbox" type="checkbox"
name="repos" name="repos"
.checked="${dep}" .checked="${dep}"
value="${dep}" .value="${dep}"
/>${dep}</label />${dep}</label
> >
`, `,
@ -302,12 +302,11 @@ class PBoard extends DecorateMixin(LitElement) {
const refSearch = `_${ref.replace('#', '_')}_`; const refSearch = `_${ref.replace('#', '_')}_`;
activeRepos.forEach(dep => { activeRepos.forEach(dep => {
const depSearch = `_${dep.replace('#', '_')}_`; const depSearch = `_${dep.replace('#', '_')}_`;
const found = this.__resultFiles[activeAnalyzer].find(({ fileName }) => { const found = this.__resultFiles[activeAnalyzer].find(
return ( ({ fileName }) =>
fileName.includes(encodeURIComponent(refSearch)) && fileName.includes(encodeURIComponent(refSearch)) &&
fileName.includes(encodeURIComponent(depSearch)) fileName.includes(encodeURIComponent(depSearch)),
); );
});
if (found) { if (found) {
jsonResultsActiveFilter.push(found.content); jsonResultsActiveFilter.push(found.content);
} else { } else {

View file

@ -103,9 +103,7 @@ describe('AjaxClient', () => {
describe('request and response interceptors', () => { describe('request and response interceptors', () => {
it('addRequestInterceptor() adds a function which intercepts the request', async () => { it('addRequestInterceptor() adds a function which intercepts the request', async () => {
ajax.addRequestInterceptor(async r => { ajax.addRequestInterceptor(async r => new Request(`${r.url}/intercepted-1`));
return new Request(`${r.url}/intercepted-1`);
});
ajax.addRequestInterceptor(async r => new Request(`${r.url}/intercepted-2`)); ajax.addRequestInterceptor(async r => new Request(`${r.url}/intercepted-2`));
await ajax.request('/foo', { method: 'POST' }); await ajax.request('/foo', { method: 'POST' });

View file

@ -4,7 +4,7 @@ import '../src/typedef.js';
import { cacheRequestInterceptorFactory, cacheResponseInterceptorFactory, ajax } from '../index.js'; import { cacheRequestInterceptorFactory, cacheResponseInterceptorFactory, ajax } from '../index.js';
describe('ajax cache', function describeLibCache() { describe('ajax cache', () => {
/** @type {number | undefined} */ /** @type {number | undefined} */
let cacheId; let cacheId;
/** @type {import('sinon').SinonStub} */ /** @type {import('sinon').SinonStub} */

View file

@ -1,3 +1,4 @@
/* eslint-disable lit-a11y/click-events-have-key-events */
import { browserDetection } from '@lion/core'; import { browserDetection } from '@lion/core';
import { aTimeout, expect, fixture, html, oneEvent, unsafeStatic } from '@open-wc/testing'; import { aTimeout, expect, fixture, html, oneEvent, unsafeStatic } from '@open-wc/testing';
import sinon from 'sinon'; import sinon from 'sinon';

View file

@ -293,7 +293,11 @@ export class GhCombobox extends LionCombobox {
</div> </div>
<div class="form-field__group-two"> <div class="form-field__group-two">
<div class="gh-section-wrapper">${this._groupTwoTemplate()}</div> <div class="gh-section-wrapper">${this._groupTwoTemplate()}</div>
<div class="gh-categories" @click="${this.__handleCategory}"> <div
class="gh-categories"
@click="${this.__handleCategory}"
@keydown="${this.__handleCategory}"
>
<button type="button" data-category="branches" class="gh-categories__btn"> <button type="button" data-category="branches" class="gh-categories__btn">
Branches Branches
</button> </button>
@ -351,8 +355,9 @@ export class GhCombobox extends LionCombobox {
get slots() { get slots() {
return { return {
...super.slots, ...super.slots,
'selection-display': () => { 'selection-display': () =>
return renderLitAsNode(html` <gh-button> renderLitAsNode(html`
<gh-button>
<svg <svg
slot="before" slot="before"
text="gray" text="gray"
@ -370,8 +375,8 @@ export class GhCombobox extends LionCombobox {
</svg> </svg>
<span slot="after"> </span> <span slot="after"> </span>
</gh-button>`); </gh-button>
}, `),
}; };
} }

View file

@ -96,7 +96,7 @@ export class GoogleOption extends LinkMixin(LionOption) {
return html` return html`
${!this.imageUrl ${!this.imageUrl
? html` <div class="google-option__icon">${googleSearchIcon}</div>` ? html` <div class="google-option__icon">${googleSearchIcon}</div>`
: html` <img class="google-option__icon" src="${this.imageUrl}" />`} : html` <img class="google-option__icon" src="${this.imageUrl}" alt="" />`}
${super.render()} ${super.render()}
`; `;
} }

View file

@ -1,3 +1,4 @@
/* eslint-disable lit-a11y/tabindex-no-positive */
import { expect, fixture, html } from '@open-wc/testing'; import { expect, fixture, html } from '@open-wc/testing';
import { LitElement } from '../index.js'; import { LitElement } from '../index.js';

View file

@ -388,9 +388,9 @@ const FormGroupMixinImplementation = superclass =>
_anyFormElementHasFeedbackFor(state) { _anyFormElementHasFeedbackFor(state) {
return Object.keys(this.formElements).some(name => { return Object.keys(this.formElements).some(name => {
if (Array.isArray(this.formElements[name])) { if (Array.isArray(this.formElements[name])) {
return this.formElements[name].some((/** @type {FormControl} */ el) => { return this.formElements[name].some((/** @type {FormControl} */ el) =>
return Boolean(el.hasFeedbackFor && el.hasFeedbackFor.includes(state)); Boolean(el.hasFeedbackFor && el.hasFeedbackFor.includes(state)),
}); );
} }
return Boolean( return Boolean(
this.formElements[name].hasFeedbackFor && this.formElements[name].hasFeedbackFor &&

View file

@ -310,7 +310,7 @@ export function runFormatMixinSuite(customConfig) {
await fixture(html` await fixture(html`
<${elem} value="${generatedViewValue}" .formatter="${formatterSpy}" <${elem} value="${generatedViewValue}" .formatter="${formatterSpy}"
.formatOptions="${{ locale: 'en-GB', decimalSeparator: '-' }}"> .formatOptions="${{ locale: 'en-GB', decimalSeparator: '-' }}">
<input slot="input" value="${generatedViewValue}"> <input slot="input" .value="${generatedViewValue}">
</${elem}> </${elem}>
`); `);
@ -327,7 +327,7 @@ export function runFormatMixinSuite(customConfig) {
const parserSpy = sinon.spy(); const parserSpy = sinon.spy();
const el = /** @type {FormatClass} */ (await fixture(html` const el = /** @type {FormatClass} */ (await fixture(html`
<${elem} .parser="${parserSpy}"> <${elem} .parser="${parserSpy}">
<input slot="input" value="${generatedValue}"> <input slot="input" .value="${generatedValue}">
</${elem}> </${elem}>
`)); `));
@ -367,7 +367,7 @@ export function runFormatMixinSuite(customConfig) {
const el = /** @type {FormatClass} */ (await fixture(html` const el = /** @type {FormatClass} */ (await fixture(html`
<${elem} .formatter=${formatterSpy}> <${elem} .formatter=${formatterSpy}>
<input slot="input" value="${generatedViewValue}"> <input slot="input" .value="${generatedViewValue}">
</${elem}> </${elem}>
`)); `));
expect(formatterSpy.callCount).to.equal(1); expect(formatterSpy.callCount).to.equal(1);

View file

@ -21,9 +21,7 @@ describe('IconManager', () => {
* @return {TemplateResult | Promise<TemplateResult> | nothing | Promise<nothing>} * @return {TemplateResult | Promise<TemplateResult> | nothing | Promise<nothing>}
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const resolver = (iconset, icon) => { const resolver = (iconset, icon) => nothing;
return nothing;
};
manager.addIconResolver('foo', resolver); manager.addIconResolver('foo', resolver);
expect(manager.__iconResolvers.get('foo')).to.equal(resolver); expect(manager.__iconResolvers.get('foo')).to.equal(resolver);

View file

@ -240,9 +240,7 @@ describe('formatDate', () => {
* @param {string} str * @param {string} str
* @returns {string} * @returns {string}
*/ */
const upperCaseProcessor = str => { const upperCaseProcessor = str => str.toUpperCase();
return str.toUpperCase();
};
/** /**
* Lowercase processor * Lowercase processor
@ -250,9 +248,7 @@ describe('formatDate', () => {
* @param {string} str * @param {string} str
* @returns {string} * @returns {string}
*/ */
const lowerCaseProcessor = str => { const lowerCaseProcessor = str => str.toLocaleLowerCase();
return str.toLocaleLowerCase();
};
it('displays the appropriate date after post processor set in options', async () => { it('displays the appropriate date after post processor set in options', async () => {
const testDate = new Date('2012/05/21'); const testDate = new Date('2012/05/21');

View file

@ -379,9 +379,7 @@ describe('formatNumber', () => {
* @param {string} str * @param {string} str
* @returns {string} * @returns {string}
*/ */
const commaToSpaceProcessor = str => { const commaToSpaceProcessor = str => str.replace(/,/g, ' ');
return str.replace(/,/g, ' ');
};
/** /**
* First space to dot processor * First space to dot processor
@ -389,9 +387,7 @@ describe('formatNumber', () => {
* @param {string} str * @param {string} str
* @returns {string} * @returns {string}
*/ */
const firstSpaceToDotProcessor = str => { const firstSpaceToDotProcessor = str => str.replace(' ', '.');
return str.replace(' ', '.');
};
it('uses `options.postProcessors`', () => { it('uses `options.postProcessors`', () => {
const postProcessors = new Map(); const postProcessors = new Map();

View file

@ -144,7 +144,7 @@ export function runOverlayMixinSuite({ tagString, tag, suffix = '' }) {
it('fires "before-closed" event on hide', async () => { it('fires "before-closed" event on hide', async () => {
const beforeSpy = sinon.spy(); const beforeSpy = sinon.spy();
const el = /** @type {OverlayEl} */ (await fixture(html` const el = /** @type {OverlayEl} */ (await fixture(html`
<${tag} @before-closed="${beforeSpy}" .opened="${true}"> <${tag} @before-closed="${beforeSpy}" opened>
<div slot="content">content of the overlay</div> <div slot="content">content of the overlay</div>
<button slot="invoker">invoker button</button> <button slot="invoker">invoker button</button>
</${tag}> </${tag}>

View file

@ -1,3 +1,4 @@
/* eslint-disable lit-a11y/click-events-have-key-events */
import { expect, fixture, fixtureSync, html } from '@open-wc/testing'; import { expect, fixture, fixtureSync, html } from '@open-wc/testing';
import { OverlayController } from '../src/OverlayController.js'; import { OverlayController } from '../src/OverlayController.js';
import { normalizeTransformStyle } from './utils-tests/local-positioning-helpers.js'; import { normalizeTransformStyle } from './utils-tests/local-positioning-helpers.js';

View file

@ -1,3 +1,4 @@
/* eslint-disable lit-a11y/no-autofocus */
import { expect, fixture, html, nextFrame } from '@open-wc/testing'; import { expect, fixture, html, nextFrame } from '@open-wc/testing';
import { renderLitAsNode } from '@lion/helpers'; import { renderLitAsNode } from '@lion/helpers';
import { getDeepActiveElement } from '../../src/utils/get-deep-active-element.js'; import { getDeepActiveElement } from '../../src/utils/get-deep-active-element.js';
@ -24,7 +25,7 @@ function simulateTabInWindow(elToRecieveFocus) {
const interactionElementsNode = renderLitAsNode(html` const interactionElementsNode = renderLitAsNode(html`
<div> <div>
<button id="el1"></button> <button id="el1"></button>
<a id="el2" href="#"></a> <a id="el2" href="#">foo</a>
<div id="el3" tabindex="0"></div> <div id="el3" tabindex="0"></div>
<input id="el4" /> <input id="el4" />
<div id="el5" contenteditable="true"></div> <div id="el5" contenteditable="true"></div>
@ -49,7 +50,7 @@ const lightDomAutofocusTemplate = html`
<div id="rootElement"> <div id="rootElement">
<button id="el1"></button> <button id="el1"></button>
<a id="el2" href="#"></a> <a id="el2" href="#">foo</a>
<div id="el3" tabindex="0"></div> <div id="el3" tabindex="0"></div>
<input id="el4" autofocus /> <input id="el4" autofocus />
<div id="el5" contenteditable="true"></div> <div id="el5" contenteditable="true"></div>

View file

@ -7,7 +7,7 @@ class ElementB extends LitElement {
render() { render() {
const marker = this.getAttribute('marker') || ''; const marker = this.getAttribute('marker') || '';
return html` return html`
<a id="el-b-${marker}-1" href="#"></a> <a id="el-b-${marker}-1" href="#">foo</a>
<div> <div>
<div id="el-b-${marker}-2" tabindex="0"> <div id="el-b-${marker}-2" tabindex="0">
@ -137,7 +137,7 @@ describe('getFocusableElements()', () => {
<slot name="slot-a"></slot> <slot name="slot-a"></slot>
<a id="el-a-2" href="#"></a> <a id="el-a-2" href="#">foo</a>
<slot></slot> <slot></slot>

View file

@ -14,7 +14,10 @@ blocker.innerText = `Shared Blocker for App`;
document.body.appendChild(blocker); document.body.appendChild(blocker);
class CompatibleManager1 extends OverlaysManager { class CompatibleManager1 extends OverlaysManager {
name = 'Compatible1 from App'; constructor() {
super();
this.name = 'Compatible1 from App';
}
block(sync = true) { block(sync = true) {
super.block(); super.block();
@ -36,7 +39,10 @@ class CompatibleManager1 extends OverlaysManager {
} }
class CompatibleManager2 extends OverlaysManager2 { class CompatibleManager2 extends OverlaysManager2 {
name = 'Compatible2 from App'; constructor() {
super();
this.name = 'Compatible2 from App';
}
blockBody(sync = true) { blockBody(sync = true) {
super.blockBody(); super.blockBody();

View file

@ -2,10 +2,9 @@ import { OverlaysManager } from 'overlays';
import { singletonManager } from '../../index.js'; import { singletonManager } from '../../index.js';
class CompatibleManager extends OverlaysManager { class CompatibleManager extends OverlaysManager {
name = 'Compatible from App';
constructor() { constructor() {
super(); super();
this.name = 'Compatible from App';
this.blocker.innerText = `Blocker for ${this.name}`; this.blocker.innerText = `Blocker for ${this.name}`;
} }

658
yarn.lock

File diff suppressed because it is too large Load diff