Skip to content

Commit

Permalink
feat: add test (#6)
Browse files Browse the repository at this point in the history
* feat: add test

* chore: update config

* update
  • Loading branch information
daflyinbed authored Aug 16, 2024
1 parent 0d5d8d6 commit 49bfdfb
Show file tree
Hide file tree
Showing 53 changed files with 1,734 additions and 46 deletions.
8 changes: 7 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
// eslint-disable-next-line antfu/no-import-dist
import { xwbx } from "./dist/index.js";

export default xwbx({ typescript: true, vue: true, astro: true, unocss: true });
export default xwbx({
ignores: ["fixtures"],
typescript: true,
vue: true,
astro: true,
unocss: true,
});
21 changes: 21 additions & 0 deletions fixtures/input/astro.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
const isJsx = true
const content = "hi!";
---

<article>
<div>{content}</div>
<div>
{isJsx && (
<h1>{content}</h1>
)}
</div>
</article>


<script>
let { log: logger } = console
document.querySelector('h1')?.addEventListener('click', () => {
logger('clicked');
});
</script>
10 changes: 10 additions & 0 deletions fixtures/input/css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@media (max-width: 480px) {
.bd-examples {margin-right: -.75rem;margin-left: -.75rem
}

.bd-examples>[class^="col-"] {
padding-right: .75rem;
padding-left: .75rem;

}
}
17 changes: 17 additions & 0 deletions fixtures/input/html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<HTML CLASS="no-js mY-ClAsS">
<HEAD>
<META CHARSET="utf-8">
<TITLE>My tITlE</TITLE>
<META NAME="description" content="My CoNtEnT">
</HEAD>
<body>
<P>Hello world!<BR> This is HTML5 Boilerplate.</P>
<SCRIPT>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</SCRIPT>
<SCRIPT
src="https://www.google-analytics.com/analytics.js" ASYNC DEFER></SCRIPT>
</body>
</HTML>
72 changes: 72 additions & 0 deletions fixtures/input/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// 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);

let a, b, c, d, foo

if (a
|| b
|| c || d
|| (d && b)
) {
foo()
}
21 changes: 21 additions & 0 deletions fixtures/input/jsx.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function HelloWorld({
greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {

if(!greeting){
return null};

// TODO: Don't use random in render
let num = Math.floor (Math.random() * 1E+7).toString()
.replace(/\.\d+/ig, "")

return <div className='HelloWorld' title={`You are visitor number ${ num }`} onMouseOver={onMouseOver}>
<strong>{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
{greeting.endsWith(",")
? " " : <span style={{color: '\grey'}}>", "</span> }
<em>
{ greeted }
</em>
{ (silent)? ".": "!"}
</div>;

}
35 changes: 35 additions & 0 deletions fixtures/input/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Header
======

_Look,_ code blocks are formatted *too!*

```js
// This should be handled by ESLint instead of Prettier
function identity(x) {
if (foo) {
console.log('bar');
}
}
```

```css
/* This should be handled by Prettier */
.foo { color:red;}
```

Pilot|Airport|Hours
--|:--:|--:
John Doe|SKG|1338
Jane Roe|JFK|314

- - - - - - - - - - - - - - -

+ List
+ with a [link] (/to/somewhere)
+ and [another one]


[another one]: http://example.com 'Example title'

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur consectetur maximus risus, sed maximus tellus tincidunt et.
8 changes: 8 additions & 0 deletions fixtures/input/svelte.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang='ts'>
export const content = "hi!"
</script>

<article>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<div>{@html content}</div>
</article>
24 changes: 24 additions & 0 deletions fixtures/input/toml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
comma = [
1
,2
,3,
]

[foo]
b = 1
c = "hello"
a = {answer = 42}

"indent" = [
1,
2
]

['a-table']
apple.type = "fruit"
orange.type = "fruit"
apple.skin = "thin"
orange.skin = "thick"

apple.color = "red"
orange.color = "orange"
10 changes: 10 additions & 0 deletions fixtures/input/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true
}
}
24 changes: 24 additions & 0 deletions fixtures/input/tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export function Component1() {
return <div/>;
}

export function jsx2() {
const props = {a:1,
b:2}
return < a foo= 'bar' bar={`foo` } >
<div {...props }
a={1}
b="2">Inline Text</div>
<Component1>
Block Text
</Component1>
<div>
Mixed
<div>Foo</div>
Text<b > Bar</b>
</div>
<p>
foo<i>bar</i><b>baz</b>
</p>
</ a >
}
80 changes: 80 additions & 0 deletions fixtures/input/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// 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())

34 changes: 34 additions & 0 deletions fixtures/input/vue-ts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<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 | 1>(0);
// Define a function
const incrementCounter = () => {
counter.value++;
};
</script>

<style>
.a { color: red }
</style>

<style lang="scss">
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body { font: 100% $font-stack;
color: $primary-color;
}
</style>
Loading

0 comments on commit 49bfdfb

Please sign in to comment.