Skip to content

Commit 4474516

Browse files
CHANGE @ W-21462752@ - Feature/eslint decorator fix tests (#427)
1 parent bcc3783 commit 4474516

10 files changed

Lines changed: 629 additions & 0 deletions

File tree

packages/code-analyzer-eslint-engine/test/parser-selection.test.ts

Lines changed: 527 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React, { useState } from 'react';
2+
3+
export default function ReactComponent({ name }) {
4+
const [count, setCount] = useState(0);
5+
6+
return (
7+
<div>
8+
<h1>Hello {name}</h1>
9+
<p>Count: {count}</p>
10+
<button onClick={() => setCount(count + 1)}>
11+
Increment
12+
</button>
13+
</div>
14+
);
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class InvalidDecorator extends LightningElement {
4+
// This will cause a parsing error if Espree is used (doesn't support decorators)
5+
@invalidDecorator
6+
someProperty;
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { LightningElement, api, track, wire } from 'lwc';
2+
import { getRecord } from 'lightning/uiRecordApi';
3+
4+
export default class LwcComponent extends LightningElement {
5+
@api recordId;
6+
@track internalState = 'initial';
7+
8+
@wire(getRecord, { recordId: '$recordId', fields: ['Account.Name'] })
9+
wiredRecord;
10+
11+
@api
12+
publicMethod() {
13+
return this.internalState;
14+
}
15+
16+
handleClick() {
17+
this.internalState = 'clicked';
18+
}
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { LightningElement, api } from 'lwc';
2+
3+
export default class MixedLwc extends LightningElement {
4+
@api title;
5+
6+
connectedCallback() {
7+
console.log('LWC component connected');
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
export default function MixedReact() {
4+
return (
5+
<div>
6+
<h2>Mixed Workspace React Component</h2>
7+
</div>
8+
);
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LightningElement, api } from 'lwc';
2+
3+
export default class ValidLwc extends LightningElement {
4+
@api validProperty;
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LightningElement, api, track } from 'lwc';
2+
3+
export default class WithViolations extends LightningElement {
4+
@api unusedProp;
5+
@track internalState;
6+
7+
connectedCallback() {
8+
debugger; // ESLint violation: no-debugger
9+
var oldStyleVar = 'test'; // ESLint violation: no-var
10+
unusedVariable = 123; // ESLint violation: no-unused-vars
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Simple TypeScript file without decorators for testing
2+
// TypeScript parser doesn't need special decorator handling like Babel
3+
4+
class TypeScriptComponent {
5+
name: string = "TypeScript";
6+
7+
constructor() {
8+
console.log("TypeScript component created");
9+
}
10+
11+
getName(): string {
12+
return this.name;
13+
}
14+
}
15+
16+
export default TypeScriptComponent;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Simple TSX component for testing TypeScript parser
2+
interface Props {
3+
title: string;
4+
}
5+
6+
function TsxComponent(props: Props) {
7+
return props.title;
8+
}
9+
10+
export default TsxComponent;

0 commit comments

Comments
 (0)