Skip to content

Commit

Permalink
test: setup integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 22, 2023
1 parent 573c0f8 commit ef021a5
Show file tree
Hide file tree
Showing 18 changed files with 643 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ dist
# IDE
.idea

*.lerna_backup
*.lerna_backup
_fixtures
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import antfu from '@antfu/eslint-config'

export default antfu(
undefined,
{
ignores: [
'fixtures',
'_fixtures',
],
},
{
files: ['**/eslint-config/src/**/*.ts'],
plugins: {
Expand Down
62 changes: 62 additions & 0 deletions fixtures/input/src/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is generated by ChatGPT

// eslint-disable-next-line no-console
var log = console.log

// Define a class using ES6 class syntax
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}

// Define a method within the class
sayHello() {
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
}
}

// Create an array of objects
const people = [
new Person('Alice', 30),
new Person('Bob', 25),
new Person('Charlie', 35)
];

// Use the forEach method to iterate over the array
people.forEach(person => {
person.sayHello();
});

// Use a template literal to create a multiline string
const multilineString = `
This is a multiline string
that spans multiple lines.
`;

// Use destructuring assignment to extract values from an object
const { name, age } = people[0];
log(`First person in the array is ${name} and they are ${age} years old.`, multilineString);

// Use the spread operator to create a new array
const numbers = [1, 2, 3];
const newNumbers = [...numbers, 4, 5];
log(newNumbers);

// Use a try-catch block for error handling
try {
// Attempt to parse an invalid JSON string
JSON.parse('invalid JSON');
} catch (error) {
console.error('Error parsing JSON:', error.message);
}

// Use a ternary conditional operator
const isEven = num => num % 2 === 0;
const number = 7;
log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`);

// Use a callback function with setTimeout for asynchronous code
setTimeout(() => {
log('This code runs after a delay of 2 seconds.');
}, 2000);
79 changes: 79 additions & 0 deletions fixtures/input/src/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Define a TypeScript interface
interface Person {
name: string;
age: number;
}

// Create an array of objects with the defined interface
const people: Person[] = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 },
{ name: 'Charlie',
age: 35 }
];

// eslint-disable-next-line no-console
var log = console.log

// Use a for...of loop to iterate over the array
for (const person of people) {
log(`Hello, my name is ${person.name} and I am ${person.age} years old.`);
}

// Define a generic function
function identity< T >(arg: T): T {
return arg;
}

// Use the generic function with type inference
const result = identity('TypeScript is awesome');
log(result);

// Use optional properties in an interface
interface Car {
make: string;
model?: string;
}

// Create objects using the interface
const car1: Car = { make: 'Toyota' };
const car2: Car = {
make: 'Ford', model: 'Focus' };

// Use union types
type Fruit = 'apple' | 'banana' | 'orange';
const favoriteFruit: Fruit = 'apple';

// Use a type assertion to tell TypeScript about the type
const inputValue: any = '42';
const numericValue = inputValue as number;

// Define a class with access modifiers
class Animal {
private name: string;
constructor(name: string) {
this.name = name;
}
protected makeSound(sound: string) {
log(`${this.name} says ${sound}`);
}
}

// Extend a class
class Dog extends Animal {
constructor(private alias: string) {
super(alias);
}
bark() {
this.makeSound('Woof!');
}
}

const dog = new Dog('Buddy');
dog.bark();

var fn = (): string => {
return 'hello' + 1
}

log(car1, car2, favoriteFruit, numericValue, fn())
20 changes: 20 additions & 0 deletions fixtures/input/src/vue-ts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<h1>{{ greeting }}</h1>
<button @click="incrementCounter">Click me!</button>
<p>Counter: {{ counter }}</p>
</div>
</template>

<script setup lang="ts">
// Define reactive data and props
import { ref } from 'vue';
const greeting = ref('Hello, Vue 3!');
let counter = ref<number | string>(0);
// Define a function
const incrementCounter = () => {
counter.value++;
};
</script>
20 changes: 20 additions & 0 deletions fixtures/input/src/vue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<h1>{{ greeting }}</h1>
<button @click="incrementCounter">Click me!</button>
<p>Counter: {{ counter }}</p>
</div>
</template>

<script setup>
// Define reactive data and props
import { ref } from 'vue';
const greeting = ref('Hello, Vue 3!');
let counter = ref(0);
// Define a function
const incrementCounter = () => {
counter.value++;
};
</script>
63 changes: 63 additions & 0 deletions fixtures/output/all/src/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// This file is generated by ChatGPT

// eslint-disable-next-line no-console
const log = console.log

// Define a class using ES6 class syntax
class Person {
constructor(name, age) {
this.name = name
this.age = age
}

// Define a method within the class
sayHello() {
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)
}
}

// Create an array of objects
const people = [
new Person('Alice', 30),
new Person('Bob', 25),
new Person('Charlie', 35),
]

// Use the forEach method to iterate over the array
people.forEach((person) => {
person.sayHello()
})

// Use a template literal to create a multiline string
const multilineString = `
This is a multiline string
that spans multiple lines.
`

// Use destructuring assignment to extract values from an object
const { name, age } = people[0]
log(`First person in the array is ${name} and they are ${age} years old.`, multilineString)

// Use the spread operator to create a new array
const numbers = [1, 2, 3]
const newNumbers = [...numbers, 4, 5]
log(newNumbers)

// Use a try-catch block for error handling
try {
// Attempt to parse an invalid JSON string
JSON.parse('invalid JSON')
}
catch (error) {
console.error('Error parsing JSON:', error.message)
}

// Use a ternary conditional operator
const isEven = num => num % 2 === 0
const number = 7
log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`)

// Use a callback function with setTimeout for asynchronous code
setTimeout(() => {
log('This code runs after a delay of 2 seconds.')
}, 2000)
81 changes: 81 additions & 0 deletions fixtures/output/all/src/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Define a TypeScript interface
interface Person {
name: string
age: number
}

// Create an array of objects with the defined interface
const people: Person[] = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 },
{ name: 'Charlie', age: 35 },
]

// eslint-disable-next-line no-console
const log = console.log

// Use a for...of loop to iterate over the array
for (const person of people)
log(`Hello, my name is ${person.name} and I am ${person.age} years old.`)

// Define a generic function
function identity< T >(arg: T): T {
return arg
}

// Use the generic function with type inference
const result = identity('TypeScript is awesome')
log(result)

// Use optional properties in an interface
interface Car {
make: string
model?: string
}

// Create objects using the interface
const car1: Car = { make: 'Toyota' }
const car2: Car = {
make: 'Ford',
model: 'Focus',
}

// Use union types
type Fruit = 'apple' | 'banana' | 'orange'
const favoriteFruit: Fruit = 'apple'

// Use a type assertion to tell TypeScript about the type
const inputValue: any = '42'
const numericValue = inputValue as number

// Define a class with access modifiers
class Animal {
private name: string
constructor(name: string) {
this.name = name
}

protected makeSound(sound: string) {
log(`${this.name} says ${sound}`)
}
}

// Extend a class
class Dog extends Animal {
constructor(private alias: string) {
super(alias)
}

bark() {
this.makeSound('Woof!')
}
}

const dog = new Dog('Buddy')
dog.bark()

function fn(): string {
return `hello${1}`
}

log(car1, car2, favoriteFruit, numericValue, fn())
22 changes: 22 additions & 0 deletions fixtures/output/all/src/vue-ts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script setup lang="ts">
// Define reactive data and props
import { ref } from 'vue'
const greeting = ref('Hello, Vue 3!')
const counter = ref<number | string>(0)
// Define a function
function incrementCounter() {
counter.value++
}
</script>

<template>
<div>
<h1>{{ greeting }}</h1>
<button @click="incrementCounter">
Click me!
</button>
<p>Counter: {{ counter }}</p>
</div>
</template>
22 changes: 22 additions & 0 deletions fixtures/output/all/src/vue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script setup>
// Define reactive data and props
import { ref } from 'vue'
const greeting = ref('Hello, Vue 3!')
const counter = ref(0)
// Define a function
function incrementCounter() {
counter.value++
}
</script>

<template>
<div>
<h1>{{ greeting }}</h1>
<button @click="incrementCounter">
Click me!
</button>
<p>Counter: {{ counter }}</p>
</div>
</template>
Loading

0 comments on commit ef021a5

Please sign in to comment.