Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
527 changes: 527 additions & 0 deletions packages/code-analyzer-eslint-engine/test/parser-selection.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, { useState } from 'react';

export default function ReactComponent({ name }) {
const [count, setCount] = useState(0);

return (
<div>
<h1>Hello {name}</h1>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { LightningElement } from 'lwc';

export default class InvalidDecorator extends LightningElement {
// This will cause a parsing error if Espree is used (doesn't support decorators)
@invalidDecorator
someProperty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LightningElement, api, track, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';

export default class LwcComponent extends LightningElement {
@api recordId;
@track internalState = 'initial';

@wire(getRecord, { recordId: '$recordId', fields: ['Account.Name'] })
wiredRecord;

@api
publicMethod() {
return this.internalState;
}

handleClick() {
this.internalState = 'clicked';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { LightningElement, api } from 'lwc';

export default class MixedLwc extends LightningElement {
@api title;

connectedCallback() {
console.log('LWC component connected');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export default function MixedReact() {
return (
<div>
<h2>Mixed Workspace React Component</h2>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LightningElement, api } from 'lwc';

export default class ValidLwc extends LightningElement {
@api validProperty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { LightningElement, api, track } from 'lwc';

export default class WithViolations extends LightningElement {
@api unusedProp;
@track internalState;

connectedCallback() {
debugger; // ESLint violation: no-debugger
var oldStyleVar = 'test'; // ESLint violation: no-var
unusedVariable = 123; // ESLint violation: no-unused-vars
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Simple TypeScript file without decorators for testing
// TypeScript parser doesn't need special decorator handling like Babel

class TypeScriptComponent {
name: string = "TypeScript";

constructor() {
console.log("TypeScript component created");
}

getName(): string {
return this.name;
}
}

export default TypeScriptComponent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Simple TSX component for testing TypeScript parser
interface Props {
title: string;
}

function TsxComponent(props: Props) {
return props.title;
}

export default TsxComponent;