Skip to content

Commit

Permalink
feat: more work on the configs
Browse files Browse the repository at this point in the history
Signed-off-by: prisis <[email protected]>
  • Loading branch information
prisis committed Jan 12, 2025
1 parent 524e693 commit 53c80cf
Show file tree
Hide file tree
Showing 105 changed files with 4,903 additions and 1,319 deletions.
21 changes: 21 additions & 0 deletions packages/eslint-config/__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 packages/eslint-config/__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 packages/eslint-config/__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>
76 changes: 76 additions & 0 deletions packages/eslint-config/__fixtures__/input/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// 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 { age, name } = 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 = number_ => number_ % 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; let b; let c; let d; let
foo;

if (a
|| b
|| c || d
|| (d && b)
) {
foo();
}
28 changes: 28 additions & 0 deletions packages/eslint-config/__fixtures__/input/jsx.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export function HelloWorld({
greeted = "\"World\"",
greeting = "hello",
onMouseOver,
silent = false
,
}) {
if (!greeting) {
return null;
}

// TODO: Don't use random in render
let number_ = Math
.floor(Math.random() * 1E+7)
.toString()
.replaceAll(/\.\d+/g, "");

return <div className='HelloWorld' onMouseOver={onMouseOver} title={`You are visitor number ${number_}`}>
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
{greeting.endsWith(",")
? " "
: <span style={{ color: "\grey" }}>", "</span> }
<em>
{ greeted }
</em>
{ silent ? "." : "!"}
</div>;
}
38 changes: 38 additions & 0 deletions packages/eslint-config/__fixtures__/input/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Header
======

_Look,_ code blocks are formatted *too!*

```js
// This should be handled by ESLint instead of Prettier
/**
*
* @param x
*/
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 packages/eslint-config/__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>
8 changes: 8 additions & 0 deletions packages/eslint-config/__fixtures__/input/svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions packages/eslint-config/__fixtures__/input/toml.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
comma = [
1,
2,
3,
]

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

[a-table]
apple.type = "fruit"
apple.skin = "thin"
apple.color = "red"

orange.type = "fruit"
orange.skin = "thick"
orange.color = "orange"
10 changes: 10 additions & 0 deletions packages/eslint-config/__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
}
}
25 changes: 25 additions & 0 deletions packages/eslint-config/__fixtures__/input/tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function Component1() {
return <div/>;
}

export function jsx2() {
const properties = {
a: 1,
b: 2,
};

return < a bar={`foo` } foo= 'bar' >
<div {...properties } 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 >;
}
91 changes: 91 additions & 0 deletions packages/eslint-config/__fixtures__/input/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Define a TypeScript interface
interface Person {
age: number;
name: string;
}

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

// 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 >(argument: T): T {
return argument;
}

// 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();

const function_ = (): string => {
return "hello" + 1;
};

log(car1, car2, favoriteFruit, numericValue, function_());
Loading

0 comments on commit 53c80cf

Please sign in to comment.