mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-05 11:31:31 +08:00
Update our custom ESLint rules to follow the official naming conventions[^1], in particular the rule names need to 1. consistently use dashes to separate words (rather a mix of underscores and dashes), and 1. consistently use `no-` prefix for rules that disallow something. Drive-by-fix: Also remove the `fixable` setting from rules that don't provide a fix. This is a functionally neutral change. [^1]: https://eslint.org/docs/latest/contribute/core-rules#rule-naming-conventions Fixed: 386319581 Change-Id: Ifcb6c0e4ca8334a263be6534596c30b3bcca243b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6110726 Reviewed-by: Samiya Caur <samiyac@chromium.org> Commit-Queue: Samiya Caur <samiyac@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
71 lines
2.7 KiB
JavaScript
71 lines
2.7 KiB
JavaScript
// 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.
|
|
|
|
const parser = require('@typescript-eslint/parser');
|
|
|
|
const utils = require('../lib/utils.js');
|
|
const {assert} = require('chai');
|
|
|
|
describe('eslint utils', () => {
|
|
describe('isLitHtmlTemplateCall', () => {
|
|
it('returns true if the code is LitHtml.html``', () => {
|
|
const code = 'LitHtml.html`<span>foo</span>`';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlTemplateCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, true);
|
|
});
|
|
|
|
it('returns true if the code is html``', () => {
|
|
const code = 'html`<span>foo</span>`';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlTemplateCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, true);
|
|
});
|
|
|
|
it('returns false if the code is LitHtml.somethingElse``', () => {
|
|
const code = 'LitHtml.somethingElse`<span>foo</span>`';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlTemplateCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, false);
|
|
});
|
|
|
|
it('returns false if the code is another tagged template function``', () => {
|
|
const code = 'notLitHtml`<span>foo</span>`';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlTemplateCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, false);
|
|
});
|
|
});
|
|
|
|
describe('isLitHtmlRenderCall', () => {
|
|
it('returns true if the code is LitHtml.render()', () => {
|
|
const code = 'LitHtml.render(LitHtml.html``, this.#shadow)';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlRenderCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, true);
|
|
});
|
|
|
|
it('returns true if the code is render()', () => {
|
|
const code = 'render(html``, this.#shadow)';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlRenderCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, true);
|
|
});
|
|
|
|
it('returns false if the code is not render()', () => {
|
|
const code = 'notRender(html``, this.#shadow)';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlRenderCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, false);
|
|
});
|
|
|
|
it('returns false if the code is LitHtml.notRender()', () => {
|
|
const code = 'LitHtml.notRender(html``, this.#shadow)';
|
|
const parsed = parser.parse(code);
|
|
const result = utils.isLitHtmlRenderCall(parsed.body[0].expression);
|
|
assert.strictEqual(result, false);
|
|
});
|
|
});
|
|
});
|