Skip to content

Commit c27ff03

Browse files
authored
Merge pull request #12 from github/eslint-plugin-custom-elements
Enable `eslint-plugin-custom-elements`
2 parents b3d2413 + 12c26db commit c27ff03

File tree

7 files changed

+48
-21
lines changed

7 files changed

+48
-21
lines changed

.eslintrc.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"root": true,
3-
"extends": ["plugin:github/browser", "plugin:github/recommended", "plugin:github/typescript"],
3+
"plugins": ["custom-elements"],
4+
"extends": [
5+
"plugin:github/browser",
6+
"plugin:github/recommended",
7+
"plugin:github/typescript",
8+
"plugin:custom-elements/recommended"
9+
],
410
"rules": {
5-
"@typescript-eslint/no-explicit-any": "off"
11+
"@typescript-eslint/no-explicit-any": "off",
12+
"custom-elements/tag-name-matches-class": ["error", {"suffix": "Element"}]
613
},
714
"globals": {
815
"FileAttachmentElement": "readonly"

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@github/prettier-config": "0.0.4",
2727
"chai": "^4.3.4",
2828
"eslint": "^7.26.0",
29+
"eslint-plugin-custom-elements": "^0.0.2",
2930
"eslint-plugin-github": "^4.1.3",
3031
"karma": "^6.3.2",
3132
"karma-chai": "^0.1.0",

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const pkg = require('./package.json')
22

33
export default {
4-
input: 'dist/index.js',
4+
input: 'dist/file-attachment-element.js',
55
output: [
66
{
77
file: pkg['module'],

src/file-attachment-element.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import Attachment from './attachment'
22

3+
// eslint-disable-next-line custom-elements/no-exports-with-element
4+
export {Attachment}
5+
36
export default class FileAttachmentElement extends HTMLElement {
47
connectedCallback(): void {
58
this.addEventListener('dragenter', onDragenter)
@@ -150,3 +153,14 @@ function onChange(event: Event) {
150153
container.attach(files)
151154
input.value = ''
152155
}
156+
157+
declare global {
158+
interface Window {
159+
FileAttachmentElement: typeof FileAttachmentElement
160+
}
161+
}
162+
163+
if (!window.customElements.get('file-attachment')) {
164+
window.FileAttachmentElement = FileAttachmentElement
165+
window.customElements.define('file-attachment', FileAttachmentElement)
166+
}

src/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
"outDir": "dist",
88
"removeComments": true
99
},
10-
"files": [
11-
"src/index.ts"
12-
]
10+
"files": ["src/file-attachment-element.ts", "src/attachment.ts"]
1311
}

0 commit comments

Comments
 (0)