diff --git a/package.json b/package.json index a6427741..5cfee3dd 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "eslint": "8.47.0", "h3": "^1.8.0", "jquery": "^3.7.0", + "lit": "^2.8.0", "typescript": "^5.1.6", "unbuild": "^1.2.1", "vitest": "^0.34.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7c1a030..3aaf3436 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,6 +63,9 @@ importers: jquery: specifier: ^3.7.0 version: 3.7.0 + lit: + specifier: ^2.8.0 + version: 2.8.0 typescript: specifier: ^5.1.6 version: 5.1.6 @@ -828,6 +831,16 @@ packages: type-detect: 4.0.8 dev: true + /@lit-labs/ssr-dom-shim@1.1.1: + resolution: {integrity: sha512-kXOeFbfCm4fFf2A3WwVEeQj55tMZa8c8/f9AKHMobQMkzNUfUj+antR3fRPaZJawsa1aZiP/Da3ndpZrwEe4rQ==} + dev: true + + /@lit/reactive-element@1.6.3: + resolution: {integrity: sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==} + dependencies: + '@lit-labs/ssr-dom-shim': 1.1.1 + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1040,6 +1053,10 @@ packages: resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==} dev: true + /@types/trusted-types@2.0.3: + resolution: {integrity: sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==} + dev: true + /@typescript-eslint/eslint-plugin@5.43.0(@typescript-eslint/parser@5.43.0)(eslint@8.47.0)(typescript@5.1.6): resolution: {integrity: sha512-wNPzG+eDR6+hhW4yobEmpR36jrqqQv1vxBq5LJO3fBAktjkvekfr4BRl+3Fn1CM/A+s8/EiGUbOMDoYqWdbtXA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -3408,6 +3425,28 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true + /lit-element@3.3.3: + resolution: {integrity: sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==} + dependencies: + '@lit-labs/ssr-dom-shim': 1.1.1 + '@lit/reactive-element': 1.6.3 + lit-html: 2.8.0 + dev: true + + /lit-html@2.8.0: + resolution: {integrity: sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==} + dependencies: + '@types/trusted-types': 2.0.3 + dev: true + + /lit@2.8.0: + resolution: {integrity: sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==} + dependencies: + '@lit/reactive-element': 1.6.3 + lit-element: 3.3.3 + lit-html: 2.8.0 + dev: true + /load-json-file@4.0.0: resolution: {integrity: sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==} engines: {node: '>=4'} diff --git a/src/utils.ts b/src/utils.ts index d95625ca..22bb655f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -19,10 +19,10 @@ export const excludeRE = [ export const importAsRE = /^.*\sas\s+/ export const separatorRE = /[,[\]{}\n]|\bimport\b/g -/** | | - * destructing case&ternary non-call | id | - * ↓ ↓ ↓ | |*/ -export const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w_$\/)])([\w_$]+)\s*(?=[.()[\]}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$)/g +/** | | + * destructing case&ternary non-call inheritance | id | + * ↓ ↓ ↓ ↓ | |*/ +export const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w_$\/)]|(?:\bextends)\s+)([\w_$]+)\s*(?=[.()[\]}}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$|(?<=extends\s+\w+)\s+{)/g const regexRE = /\/[^\s]*?(? { } ] }, + { + from: 'lit', + imports: ['LitElement'] + }, { from: 'three', imports: [['*', 'THREE']] diff --git a/test/cases/positive/extends.output.ts b/test/cases/positive/extends.output.ts new file mode 100644 index 00000000..ad2b73d6 --- /dev/null +++ b/test/cases/positive/extends.output.ts @@ -0,0 +1,2 @@ +import { LitElement } from 'lit'; +class MyElement extends LitElement {} diff --git a/test/cases/positive/extends.ts b/test/cases/positive/extends.ts new file mode 100644 index 00000000..3184d236 --- /dev/null +++ b/test/cases/positive/extends.ts @@ -0,0 +1 @@ +class MyElement extends LitElement {}