Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Oct 11, 2023
1 parent 2ae7712 commit fe89bef
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 293 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Install Dev
if: steps.cache-dev.outputs.cache-hit != 'true'
run: npm ci
working-directory: 'dev'
working-directory: "dev"

- name: Test
run: npm run test:all
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname -- "$0")/_/husky.sh"

npx eslint --fix
# npx prettier --write
npx prettier --write .
18 changes: 10 additions & 8 deletions ANALYZE.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,30 @@ In addition, the entire content of HTMLElement is copied into the interfaces, so

### Component discovery

An LWC component class is automatically identified from a JavaScript/Typescript file if:
An LWC component class is automatically identified from a JavaScript/Typescript file if:

- It is the default export of the file
- The JS file name equals the parent folder name (ex: `/../mycomp/mycomp.{js|ts}`)
- There is an HTML template with the same name in the same folder (ex: `/../mycomp/mycomp.html`)
- There is an HTML template with the same name in the same folder (ex: `/../mycomp/mycomp.html`)

The component is named after the last 2 parts of its parent directory. For example, if the file path is
`/../myns/mycomp/mycomp.js`, then the component tag is `myns-mycomp`. The name is also transformed from camel case
to dash case: `/../myns/mycomp/myComp.js` leads to `myns-my-comp`.
to dash case: `/../myns/mycomp/myComp.js` leads to `myns-my-comp`.

For components that are not following the previous naming scheme, it uses 2 other methods:

For components that are not following the previous naming scheme, it uses 2 other methods:
- Checks if the class extends `LightningElement`.
This only works with a direct inheritance as it doesn't check the whole hierarchy.
This only works with a direct inheritance as it doesn't check the whole hierarchy.

- Looks for a `@lwcelement` JSDoc tag.
The JSDoc tag can also override the default tag name.
The JSDoc tag can also override the default tag name.

```javascript
/**
* @lwcelement my-element
*/
export default class MyElement extends BaseComponent {
```
```
#### In your own code
Expand Down Expand Up @@ -249,4 +251,4 @@ export default class MyElement extends LightningElement {
*/
@api prop3;
}
```
```
524 changes: 262 additions & 262 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/src/lit-element/lit-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MyElement extends LitElement {
};
}

update(changedProperties: Map<PropertyKey, unknown>): void {
update(changedProperties) {
super.update();
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ o {tagname}: The element's tag name`,
.strict()
.alias("h", "help").argv;

if ((argv as {verbose: boolean}).verbose) {
if ((argv as { verbose: boolean }).verbose) {
/* eslint-disable-next-line no-console */
console.log("CLI options:", argv);
}
Expand Down
10 changes: 2 additions & 8 deletions test/flavors/custom-element/discover-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,8 @@ tsTest("Correctly discovers multiple declarations", t => {

t.is(componentDefinitions.length, 1);
t.is(componentDefinitions[0].tagName, "my-element");
t.is(
componentDefinitions[0].declaration?.members?.some(m => m.propName === "prototype"),
false
);
t.is(
componentDefinitions[0].declaration?.methods?.some(m => m.name === "new"),
false
);
t.is(componentDefinitions[0].declaration?.members?.some(m => m.propName === "prototype"), false);
t.is(componentDefinitions[0].declaration?.methods?.some(m => m.name === "new"), false);
});

tsTest("Discovers elements using typescript >=4.3 syntax", t => {
Expand Down
2 changes: 1 addition & 1 deletion test/flavors/lwc/comp/c0/c0.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template>
<div>Hi!</div>
<div>Hi!</div>
</template>
5 changes: 2 additions & 3 deletions test/flavors/lwc/comp/c0/c0.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LightningElement } from 'lwc';
import { LightningElement } from "lwc";

/**
* Simple component.
*/
export default class C0 extends LightningElement {
}
export default class C0 extends LightningElement {}
5 changes: 2 additions & 3 deletions test/flavors/lwc/comp/c1/c1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LightningElement } from 'lwc';
import { LightningElement } from "lwc";

/**
* Simple component.
*/
export default class C1 extends LightningElement {
}
export default class C1 extends LightningElement {}
5 changes: 2 additions & 3 deletions test/flavors/lwc/comp/c2/c2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { OtherElement } from 'lwc';
import { OtherElement } from "lwc";

/**
* Simple component.
*/
export default class C3 extends OtherElement {
}
export default class C3 extends OtherElement {}
2 changes: 1 addition & 1 deletion test/helpers/ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type TestFunction = (title: string, implementation: Implementation) => void;

const TS_MODULES_ALL = ["current", "4.8", "4.9", "5.0", "5.1"] as const;

type TsModuleKind = typeof TS_MODULES_ALL[number];
type TsModuleKind = (typeof TS_MODULES_ALL)[number];

const TS_MODULES_DEFAULT: readonly TsModuleKind[] = TS_MODULES_ALL;

Expand Down

0 comments on commit fe89bef

Please sign in to comment.