From fbbaf6d021f136c26177e7782011320ab7392a2b Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 3 Apr 2023 17:39:45 +0100 Subject: [PATCH 1/4] move AOR to primer --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index e6bf555..68f394d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @github/web-systems-reviewers +* @github/primer-reviewers From 7519292c9d2bc07b799602a55d37f6fee9e0487e Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Sun, 9 Apr 2023 08:49:21 +0100 Subject: [PATCH 2/4] Ensure CI runs for pulls --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index bbc4fbb..2d98616 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,6 +1,6 @@ name: Node CI -on: [push] +on: [push, pull_request] jobs: build: From c431e3484355b47322a48936c32bcf8c2987aa37 Mon Sep 17 00:00:00 2001 From: Actions Auto Build Date: Sun, 9 Apr 2023 07:49:53 +0000 Subject: [PATCH 3/4] style: format markdown files --- docs/rules/no-exports-with-element.md | 2 +- package-lock.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/rules/no-exports-with-element.md b/docs/rules/no-exports-with-element.md index 280e632..ec39d3e 100644 --- a/docs/rules/no-exports-with-element.md +++ b/docs/rules/no-exports-with-element.md @@ -33,7 +33,7 @@ export class FooBarElement extends HTMLElement { // foo-bar-element.js import {myHelper} from './helpers.js' export class FooReadyEvent extends Event { - // ... + // ... } export class FooBarElement extends HTMLElement { diff --git a/package-lock.json b/package-lock.json index 403e041..26f5080 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "eslint-plugin-custom-elements", "version": "0.0.5", "license": "MIT", "devDependencies": { From 837fb4dcb56dc1de1695b6f801c5ca435511ad8b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 9 Apr 2023 09:51:39 +0200 Subject: [PATCH 4/4] file-name-matches-element: Fix case of missing name (#58) Fixes: https://github.com/github/eslint-plugin-custom-elements/issues/57 Co-authored-by: Keith Cirkel --- lib/rules/file-name-matches-element.js | 9 ++++++--- test/file-name-matches-element.js | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/rules/file-name-matches-element.js b/lib/rules/file-name-matches-element.js index a5ff4ef..c6b897e 100644 --- a/lib/rules/file-name-matches-element.js +++ b/lib/rules/file-name-matches-element.js @@ -48,8 +48,11 @@ module.exports = { if (!hasFileName(context)) return {} return { [s.HTMLElementClass](node) { - const name = node.id.name - const names = [name] + const name = node.id?.name + const names = [] + if (name) { + names.push(name) + } const filename = basename(context.getFilename(), extname(context.getFilename())) const transforms = [].concat(context.options?.[0]?.transform || ['kebab', 'pascal']) const suffixes = [].concat(context.options?.[0]?.suffix || []) @@ -66,7 +69,7 @@ module.exports = { allowedFileNames.add(transformFuncs[transform](className)) } } - if (!allowedFileNames.has(filename)) { + if (allowedFileNames.size && !allowedFileNames.has(filename)) { const allowed = Array.from(allowedFileNames).join('" or "') context.report(node, `File name should be "${allowed}" but was "${filename}"`) } diff --git a/test/file-name-matches-element.js b/test/file-name-matches-element.js index 9677222..0b736f0 100644 --- a/test/file-name-matches-element.js +++ b/test/file-name-matches-element.js @@ -51,6 +51,10 @@ ruleTester.run('file-name-matches-element', rule, { filename: 'components/foo/foo-bar.ts', options: [{transform: 'kebab', suffix: ['Controller']}], }, + { + code: 'window.customElements.define("foo-bar", class extends HTMLElement {})', + filename: 'any.js', + }, ], invalid: [ {