From 5b406b0b7cb00893b4e62ee450ee0818b1dd8bb3 Mon Sep 17 00:00:00 2001 From: nirtamir2 Date: Fri, 28 Feb 2025 19:02:36 +0200 Subject: [PATCH] Update dependencies and rules, add storybook and query configs (#4) --- README.md | 6 +- eslint.config.ts | 25 +- fixtures/input/jsx.jsx | 2 +- fixtures/output/all/jsx.jsx | 2 +- fixtures/output/js/javascript.js | 71 ------ fixtures/output/js/jsx.jsx | 34 --- fixtures/output/js/markdown.md | 35 --- fixtures/output/js/toml.toml | 23 -- fixtures/output/js/tsx.tsx | 26 --- .../no-markdown-with-formatters/javascript.js | 71 ------ .../no-markdown-with-formatters/markdown.md | 35 --- .../no-markdown-with-formatters/toml.toml | 23 -- .../no-markdown-with-formatters/tsx.tsx | 24 -- .../no-markdown-with-formatters/typescript.ts | 82 ------- fixtures/output/no-style/javascript.js | 71 ------ fixtures/output/no-style/jsx.jsx | 34 --- fixtures/output/no-style/toml.toml | 23 -- fixtures/output/no-style/typescript.ts | 80 ------- fixtures/output/no-style/vue-ts.vue | 36 --- fixtures/output/no-style/vue.vue | 25 -- .../output/tab-double-quotes/javascript.js | 71 ------ fixtures/output/tab-double-quotes/jsx.jsx | 34 --- fixtures/output/tab-double-quotes/markdown.md | 35 --- fixtures/output/tab-double-quotes/toml.toml | 23 -- fixtures/output/tab-double-quotes/tsx.tsx | 26 --- .../output/tab-double-quotes/typescript.ts | 82 ------- fixtures/output/tab-double-quotes/vue-ts.vue | 36 --- fixtures/output/tab-double-quotes/vue.vue | 25 -- fixtures/output/ts-override/javascript.js | 71 ------ fixtures/output/ts-override/jsx.jsx | 34 --- fixtures/output/ts-override/toml.toml | 23 -- fixtures/output/ts-override/typescript.ts | 82 ------- fixtures/output/ts-override/vue-ts.vue | 36 --- fixtures/output/ts-override/vue.vue | 25 -- fixtures/output/with-formatters/astro.astro | 18 -- fixtures/output/with-formatters/css.css | 11 - fixtures/output/with-formatters/html.html | 28 --- fixtures/output/with-formatters/javascript.js | 71 ------ fixtures/output/with-formatters/jsx.jsx | 34 --- fixtures/output/with-formatters/markdown.md | 35 --- fixtures/output/with-formatters/toml.toml | 23 -- fixtures/output/with-formatters/tsx.tsx | 26 --- fixtures/output/with-formatters/typescript.ts | 82 ------- fixtures/output/with-formatters/vue-ts.vue | 36 --- fixtures/output/with-formatters/vue.vue | 25 -- fixtures/output/with-formatters/xml.xml | 20 -- package.json | 221 +++++++++--------- pnpm-lock.yaml | 10 +- scripts/typegen.ts | 2 + src/cli.ts | 2 +- src/cli/constants.ts | 2 +- src/cli/index.ts | 2 +- src/cli/run.ts | 28 ++- src/cli/stages/update-eslint-files.ts | 4 +- src/cli/stages/update-package-json.ts | 2 +- src/configs/astro.ts | 3 +- src/configs/i18n.ts | 20 +- src/configs/javascript.ts | 52 ++--- src/configs/jsonc.ts | 2 +- src/configs/markdown.ts | 2 +- src/configs/query.ts | 16 +- src/configs/react.ts | 4 +- src/configs/solid.ts | 6 +- src/configs/storybook.ts | 33 ++- src/configs/stylistic.ts | 8 +- src/configs/svelte.ts | 2 +- src/configs/toml.ts | 2 +- src/configs/typescript.ts | 102 +++++--- src/configs/unicorn.ts | 2 - src/configs/vue.ts | 4 +- src/configs/yaml.ts | 2 +- src/factory.ts | 25 +- src/index.ts | 2 +- src/plugins.ts | 2 +- src/stub.d.ts | 1 + src/types.ts | 75 +++++- src/utils.ts | 2 +- test/cli.spec.ts | 35 +-- test/fixtures.test.ts | 56 ++--- tsconfig.json | 2 +- 80 files changed, 443 insertions(+), 2030 deletions(-) delete mode 100644 fixtures/output/js/javascript.js delete mode 100644 fixtures/output/js/jsx.jsx delete mode 100644 fixtures/output/js/markdown.md delete mode 100644 fixtures/output/js/toml.toml delete mode 100644 fixtures/output/js/tsx.tsx delete mode 100644 fixtures/output/no-markdown-with-formatters/javascript.js delete mode 100644 fixtures/output/no-markdown-with-formatters/markdown.md delete mode 100644 fixtures/output/no-markdown-with-formatters/toml.toml delete mode 100644 fixtures/output/no-markdown-with-formatters/tsx.tsx delete mode 100644 fixtures/output/no-markdown-with-formatters/typescript.ts delete mode 100644 fixtures/output/no-style/javascript.js delete mode 100644 fixtures/output/no-style/jsx.jsx delete mode 100644 fixtures/output/no-style/toml.toml delete mode 100644 fixtures/output/no-style/typescript.ts delete mode 100644 fixtures/output/no-style/vue-ts.vue delete mode 100644 fixtures/output/no-style/vue.vue delete mode 100644 fixtures/output/tab-double-quotes/javascript.js delete mode 100644 fixtures/output/tab-double-quotes/jsx.jsx delete mode 100644 fixtures/output/tab-double-quotes/markdown.md delete mode 100644 fixtures/output/tab-double-quotes/toml.toml delete mode 100644 fixtures/output/tab-double-quotes/tsx.tsx delete mode 100644 fixtures/output/tab-double-quotes/typescript.ts delete mode 100644 fixtures/output/tab-double-quotes/vue-ts.vue delete mode 100644 fixtures/output/tab-double-quotes/vue.vue delete mode 100644 fixtures/output/ts-override/javascript.js delete mode 100644 fixtures/output/ts-override/jsx.jsx delete mode 100644 fixtures/output/ts-override/toml.toml delete mode 100644 fixtures/output/ts-override/typescript.ts delete mode 100644 fixtures/output/ts-override/vue-ts.vue delete mode 100644 fixtures/output/ts-override/vue.vue delete mode 100644 fixtures/output/with-formatters/astro.astro delete mode 100644 fixtures/output/with-formatters/css.css delete mode 100644 fixtures/output/with-formatters/html.html delete mode 100644 fixtures/output/with-formatters/javascript.js delete mode 100644 fixtures/output/with-formatters/jsx.jsx delete mode 100644 fixtures/output/with-formatters/markdown.md delete mode 100644 fixtures/output/with-formatters/toml.toml delete mode 100644 fixtures/output/with-formatters/tsx.tsx delete mode 100644 fixtures/output/with-formatters/typescript.ts delete mode 100644 fixtures/output/with-formatters/vue-ts.vue delete mode 100644 fixtures/output/with-formatters/vue.vue delete mode 100644 fixtures/output/with-formatters/xml.xml diff --git a/README.md b/README.md index 95d9e5b797..5bff0d4bc9 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ For example: ```json { "scripts": { - "lint": "eslint .", - "lint:fix": "eslint . --fix" + "lint": "eslint", + "lint:fix": "eslint --fix" } } ``` @@ -301,7 +301,7 @@ const foo = async (msg: string): void => { }; ``` -Will be transformed to this when you hit save with your editor or run `eslint . --fix`: +Will be transformed to this when you hit save with your editor or run `eslint --fix`: ```ts async function foo(msg: string): void { diff --git a/eslint.config.ts b/eslint.config.ts index 8c9d43d010..6e922988c9 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -7,13 +7,36 @@ export default nirtamir2( solid: true, svelte: true, astro: true, - typescript: true, + storybook: true, + query: true, + typescript: { + tsconfigPath: "tsconfig.json", + }, formatters: false, stylistic: false, }, [ + { ignores: [".prettierrc.mjs", "README.md"] }, { rules: { + "@typescript-eslint/promise-function-async": "off", + "@typescript-eslint/strict-boolean-expressions": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/prefer-nullish-coalescing": "off", + "@typescript-eslint/no-unnecessary-condition": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "sonarjs/deprecation": "off", + "@typescript-eslint/no-deprecated": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-redundant-type-constituents": "off", + "sonarjs/no-redundant-optional": "off", + "no-use-before-define": "off", + "@typescript-eslint/no-unnecessary-type-parameters": "off", + // "@typescript-eslint/init-declarations": "off", "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", diff --git a/fixtures/input/jsx.jsx b/fixtures/input/jsx.jsx index 250b2851f4..aff098f2a8 100644 --- a/fixtures/input/jsx.jsx +++ b/fixtures/input/jsx.jsx @@ -15,7 +15,7 @@ export function HelloWorld({ return (
diff --git a/fixtures/output/all/jsx.jsx b/fixtures/output/all/jsx.jsx index 5fe8bfd271..94f368d0e8 100644 --- a/fixtures/output/all/jsx.jsx +++ b/fixtures/output/all/jsx.jsx @@ -15,7 +15,7 @@ export function HelloWorld({ return (
diff --git a/fixtures/output/js/javascript.js b/fixtures/output/js/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/js/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/js/jsx.jsx b/fixtures/output/js/jsx.jsx deleted file mode 100644 index 5fe8bfd271..0000000000 --- a/fixtures/output/js/jsx.jsx +++ /dev/null @@ -1,34 +0,0 @@ -export function HelloWorld({ - greeting = "hello", - greeted = '"World"', - silent = false, - onMouseOver, -}) { - if (!greeting) { - return null; - } - - // TODO: Don't use random in render - const num = Math.floor(Math.random() * 1e7) - .toString() - .replace(/\.\d+/g, ""); - - return ( -
- - {greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()} - - {greeting.endsWith(",") ? ( - " " - ) : ( - ", " - )} - {greeted} - {silent ? "." : "!"} -
- ); -} diff --git a/fixtures/output/js/markdown.md b/fixtures/output/js/markdown.md deleted file mode 100644 index 6b24021562..0000000000 --- a/fixtures/output/js/markdown.md +++ /dev/null @@ -1,35 +0,0 @@ -# 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. diff --git a/fixtures/output/js/toml.toml b/fixtures/output/js/toml.toml deleted file mode 100644 index 1f73d046bd..0000000000 --- a/fixtures/output/js/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/js/tsx.tsx b/fixtures/output/js/tsx.tsx deleted file mode 100644 index 550b2ee0a1..0000000000 --- a/fixtures/output/js/tsx.tsx +++ /dev/null @@ -1,26 +0,0 @@ -export function Component1() { - return
; -} - -export function jsx2() { - const props = { a: 1, b: 2 }; - return ( - -
- Inline Text -
- Block Text -
- Mixed -
Foo
- Text - Bar -
-

- foo - bar - baz -

-
- ); -} diff --git a/fixtures/output/no-markdown-with-formatters/javascript.js b/fixtures/output/no-markdown-with-formatters/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/no-markdown-with-formatters/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/no-markdown-with-formatters/markdown.md b/fixtures/output/no-markdown-with-formatters/markdown.md deleted file mode 100644 index 6b24021562..0000000000 --- a/fixtures/output/no-markdown-with-formatters/markdown.md +++ /dev/null @@ -1,35 +0,0 @@ -# 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. diff --git a/fixtures/output/no-markdown-with-formatters/toml.toml b/fixtures/output/no-markdown-with-formatters/toml.toml deleted file mode 100644 index 1f73d046bd..0000000000 --- a/fixtures/output/no-markdown-with-formatters/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/no-markdown-with-formatters/tsx.tsx b/fixtures/output/no-markdown-with-formatters/tsx.tsx deleted file mode 100644 index 6fa1309eb2..0000000000 --- a/fixtures/output/no-markdown-with-formatters/tsx.tsx +++ /dev/null @@ -1,24 +0,0 @@ -export function Component1() { - return
; -} - -export function jsx2() { - const props = { a: 1, b: 2 }; - return ( - -
- Inline Text -
- Block Text -
- Mixed -
Foo
- Text Bar -
-

- foobar - baz -

-
- ); -} diff --git a/fixtures/output/no-markdown-with-formatters/typescript.ts b/fixtures/output/no-markdown-with-formatters/typescript.ts deleted file mode 100644 index 1c175a1517..0000000000 --- a/fixtures/output/no-markdown-with-formatters/typescript.ts +++ /dev/null @@ -1,82 +0,0 @@ -// 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(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()); diff --git a/fixtures/output/no-style/javascript.js b/fixtures/output/no-style/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/no-style/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/no-style/jsx.jsx b/fixtures/output/no-style/jsx.jsx deleted file mode 100644 index 5fe8bfd271..0000000000 --- a/fixtures/output/no-style/jsx.jsx +++ /dev/null @@ -1,34 +0,0 @@ -export function HelloWorld({ - greeting = "hello", - greeted = '"World"', - silent = false, - onMouseOver, -}) { - if (!greeting) { - return null; - } - - // TODO: Don't use random in render - const num = Math.floor(Math.random() * 1e7) - .toString() - .replace(/\.\d+/g, ""); - - return ( -
- - {greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()} - - {greeting.endsWith(",") ? ( - " " - ) : ( - ", " - )} - {greeted} - {silent ? "." : "!"} -
- ); -} diff --git a/fixtures/output/no-style/toml.toml b/fixtures/output/no-style/toml.toml deleted file mode 100644 index a28003c425..0000000000 --- a/fixtures/output/no-style/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/no-style/typescript.ts b/fixtures/output/no-style/typescript.ts deleted file mode 100644 index db36442584..0000000000 --- a/fixtures/output/no-style/typescript.ts +++ /dev/null @@ -1,80 +0,0 @@ -// 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(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(); - -const fn = (): string => { - return `hello${1}`; -}; - -log(car1, car2, favoriteFruit, numericValue, fn()); diff --git a/fixtures/output/no-style/vue-ts.vue b/fixtures/output/no-style/vue-ts.vue deleted file mode 100644 index 8a94fc878a..0000000000 --- a/fixtures/output/no-style/vue-ts.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/fixtures/output/no-style/vue.vue b/fixtures/output/no-style/vue.vue deleted file mode 100644 index 33d19d573c..0000000000 --- a/fixtures/output/no-style/vue.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/fixtures/output/tab-double-quotes/javascript.js b/fixtures/output/tab-double-quotes/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/tab-double-quotes/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/tab-double-quotes/jsx.jsx b/fixtures/output/tab-double-quotes/jsx.jsx deleted file mode 100644 index 5fe8bfd271..0000000000 --- a/fixtures/output/tab-double-quotes/jsx.jsx +++ /dev/null @@ -1,34 +0,0 @@ -export function HelloWorld({ - greeting = "hello", - greeted = '"World"', - silent = false, - onMouseOver, -}) { - if (!greeting) { - return null; - } - - // TODO: Don't use random in render - const num = Math.floor(Math.random() * 1e7) - .toString() - .replace(/\.\d+/g, ""); - - return ( -
- - {greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()} - - {greeting.endsWith(",") ? ( - " " - ) : ( - ", " - )} - {greeted} - {silent ? "." : "!"} -
- ); -} diff --git a/fixtures/output/tab-double-quotes/markdown.md b/fixtures/output/tab-double-quotes/markdown.md deleted file mode 100644 index 6b24021562..0000000000 --- a/fixtures/output/tab-double-quotes/markdown.md +++ /dev/null @@ -1,35 +0,0 @@ -# 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. diff --git a/fixtures/output/tab-double-quotes/toml.toml b/fixtures/output/tab-double-quotes/toml.toml deleted file mode 100644 index 1f73d046bd..0000000000 --- a/fixtures/output/tab-double-quotes/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/tab-double-quotes/tsx.tsx b/fixtures/output/tab-double-quotes/tsx.tsx deleted file mode 100644 index 550b2ee0a1..0000000000 --- a/fixtures/output/tab-double-quotes/tsx.tsx +++ /dev/null @@ -1,26 +0,0 @@ -export function Component1() { - return
; -} - -export function jsx2() { - const props = { a: 1, b: 2 }; - return ( - -
- Inline Text -
- Block Text -
- Mixed -
Foo
- Text - Bar -
-

- foo - bar - baz -

-
- ); -} diff --git a/fixtures/output/tab-double-quotes/typescript.ts b/fixtures/output/tab-double-quotes/typescript.ts deleted file mode 100644 index 1c175a1517..0000000000 --- a/fixtures/output/tab-double-quotes/typescript.ts +++ /dev/null @@ -1,82 +0,0 @@ -// 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(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()); diff --git a/fixtures/output/tab-double-quotes/vue-ts.vue b/fixtures/output/tab-double-quotes/vue-ts.vue deleted file mode 100644 index 37620904b1..0000000000 --- a/fixtures/output/tab-double-quotes/vue-ts.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/fixtures/output/tab-double-quotes/vue.vue b/fixtures/output/tab-double-quotes/vue.vue deleted file mode 100644 index 42770de608..0000000000 --- a/fixtures/output/tab-double-quotes/vue.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/fixtures/output/ts-override/javascript.js b/fixtures/output/ts-override/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/ts-override/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/ts-override/jsx.jsx b/fixtures/output/ts-override/jsx.jsx deleted file mode 100644 index 5fe8bfd271..0000000000 --- a/fixtures/output/ts-override/jsx.jsx +++ /dev/null @@ -1,34 +0,0 @@ -export function HelloWorld({ - greeting = "hello", - greeted = '"World"', - silent = false, - onMouseOver, -}) { - if (!greeting) { - return null; - } - - // TODO: Don't use random in render - const num = Math.floor(Math.random() * 1e7) - .toString() - .replace(/\.\d+/g, ""); - - return ( -
- - {greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()} - - {greeting.endsWith(",") ? ( - " " - ) : ( - ", " - )} - {greeted} - {silent ? "." : "!"} -
- ); -} diff --git a/fixtures/output/ts-override/toml.toml b/fixtures/output/ts-override/toml.toml deleted file mode 100644 index 1f73d046bd..0000000000 --- a/fixtures/output/ts-override/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/ts-override/typescript.ts b/fixtures/output/ts-override/typescript.ts deleted file mode 100644 index 6f1db4edd8..0000000000 --- a/fixtures/output/ts-override/typescript.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Define a TypeScript interface -type 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(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 -type 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()); diff --git a/fixtures/output/ts-override/vue-ts.vue b/fixtures/output/ts-override/vue-ts.vue deleted file mode 100644 index 37620904b1..0000000000 --- a/fixtures/output/ts-override/vue-ts.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/fixtures/output/ts-override/vue.vue b/fixtures/output/ts-override/vue.vue deleted file mode 100644 index 42770de608..0000000000 --- a/fixtures/output/ts-override/vue.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/fixtures/output/with-formatters/astro.astro b/fixtures/output/with-formatters/astro.astro deleted file mode 100644 index fb1c8f943b..0000000000 --- a/fixtures/output/with-formatters/astro.astro +++ /dev/null @@ -1,18 +0,0 @@ ---- -const isJsx = true; -const content = "hi!"; ---- - -
-
{content}
-
- {isJsx &&

{content}

} -
-
- - diff --git a/fixtures/output/with-formatters/css.css b/fixtures/output/with-formatters/css.css deleted file mode 100644 index 077c7601aa..0000000000 --- a/fixtures/output/with-formatters/css.css +++ /dev/null @@ -1,11 +0,0 @@ -@media (max-width: 480px) { - .bd-examples { - margin-right: -0.75rem; - margin-left: -0.75rem; - } - - .bd-examples > [class^="col-"] { - padding-right: 0.75rem; - padding-left: 0.75rem; - } -} diff --git a/fixtures/output/with-formatters/html.html b/fixtures/output/with-formatters/html.html deleted file mode 100644 index 30e8a3a415..0000000000 --- a/fixtures/output/with-formatters/html.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - My tITlE - - - -

- Hello world!
- This is HTML5 Boilerplate. -

- - - - diff --git a/fixtures/output/with-formatters/javascript.js b/fixtures/output/with-formatters/javascript.js deleted file mode 100644 index a6b2a2269f..0000000000 --- a/fixtures/output/with-formatters/javascript.js +++ /dev/null @@ -1,71 +0,0 @@ -// 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); - -let a, b, c, d, foo; - -if (a || b || c || d || (d && b)) { - foo(); -} diff --git a/fixtures/output/with-formatters/jsx.jsx b/fixtures/output/with-formatters/jsx.jsx deleted file mode 100644 index 5fe8bfd271..0000000000 --- a/fixtures/output/with-formatters/jsx.jsx +++ /dev/null @@ -1,34 +0,0 @@ -export function HelloWorld({ - greeting = "hello", - greeted = '"World"', - silent = false, - onMouseOver, -}) { - if (!greeting) { - return null; - } - - // TODO: Don't use random in render - const num = Math.floor(Math.random() * 1e7) - .toString() - .replace(/\.\d+/g, ""); - - return ( -
- - {greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()} - - {greeting.endsWith(",") ? ( - " " - ) : ( - ", " - )} - {greeted} - {silent ? "." : "!"} -
- ); -} diff --git a/fixtures/output/with-formatters/markdown.md b/fixtures/output/with-formatters/markdown.md deleted file mode 100644 index 6b24021562..0000000000 --- a/fixtures/output/with-formatters/markdown.md +++ /dev/null @@ -1,35 +0,0 @@ -# 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. diff --git a/fixtures/output/with-formatters/toml.toml b/fixtures/output/with-formatters/toml.toml deleted file mode 100644 index 1f73d046bd..0000000000 --- a/fixtures/output/with-formatters/toml.toml +++ /dev/null @@ -1,23 +0,0 @@ -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" diff --git a/fixtures/output/with-formatters/tsx.tsx b/fixtures/output/with-formatters/tsx.tsx deleted file mode 100644 index 550b2ee0a1..0000000000 --- a/fixtures/output/with-formatters/tsx.tsx +++ /dev/null @@ -1,26 +0,0 @@ -export function Component1() { - return
; -} - -export function jsx2() { - const props = { a: 1, b: 2 }; - return ( - -
- Inline Text -
- Block Text -
- Mixed -
Foo
- Text - Bar -
-

- foo - bar - baz -

-
- ); -} diff --git a/fixtures/output/with-formatters/typescript.ts b/fixtures/output/with-formatters/typescript.ts deleted file mode 100644 index 1c175a1517..0000000000 --- a/fixtures/output/with-formatters/typescript.ts +++ /dev/null @@ -1,82 +0,0 @@ -// 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(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()); diff --git a/fixtures/output/with-formatters/vue-ts.vue b/fixtures/output/with-formatters/vue-ts.vue deleted file mode 100644 index 37620904b1..0000000000 --- a/fixtures/output/with-formatters/vue-ts.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/fixtures/output/with-formatters/vue.vue b/fixtures/output/with-formatters/vue.vue deleted file mode 100644 index 42770de608..0000000000 --- a/fixtures/output/with-formatters/vue.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/fixtures/output/with-formatters/xml.xml b/fixtures/output/with-formatters/xml.xml deleted file mode 100644 index 88571e3d82..0000000000 --- a/fixtures/output/with-formatters/xml.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - Effective Java - 45.00 - - - Bluetooth Speaker - 120.00 - - - Clean Code - 33.50 - - - - - - - - diff --git a/package.json b/package.json index d6d811f878..a6df5b1f4d 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,15 @@ { "name": "@nirtamir2/eslint-config", - "type": "module", "version": "0.0.2-beta.20", - "packageManager": "pnpm@10.4.1", "description": "Nir Tamir's ESLint config", - "author": "Nir Tami (https://github.com/nirtamir2/)", - "license": "MIT", - "funding": "https://github.com/sponsors/nirtamir2", - "homepage": "https://github.com/nirtamir2/eslint-config", "keywords": [ "eslint-config" ], + "homepage": "https://github.com/nirtamir2/eslint-config", + "funding": "https://github.com/sponsors/nirtamir2", + "license": "MIT", + "author": "Nir Tami (https://github.com/nirtamir2/)", + "type": "module", "exports": { ".": "./dist/index.js" }, @@ -26,107 +25,28 @@ "build:inspector": "pnpm build && npx @eslint/config-inspector build", "dev": "npx @eslint/config-inspector --config eslint.config.ts", "format": "prettier \"**/*\" --write --ignore-unknown", - "lint": "eslint . --fix", + "lint": "eslint --fix", "prepack": "nr build", "prepare": "simple-git-hooks", "release": "bumpp && pnpm publish", "stub": "tsup", "test": "vitest", - "typecheck": "tsc --noEmit", "type-check": "tsc --noEmit", + "typecheck": "tsc --noEmit", "typegen": "esno scripts/typegen.ts", "watch": "tsup --watch" }, - "peerDependencies": { - "@eslint-react/eslint-plugin": "^1.15.0", - "@prettier/plugin-xml": "^3.4.1", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", - "@unocss/eslint-plugin": "^0.63.4", - "astro-eslint-parser": "^1.0.3", - "eslint": "^9.13.0", - "eslint-plugin-astro": "^1.3.0", - "eslint-plugin-format": "^0.1.2", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.13", - "eslint-plugin-solid": "^0.14.3", - "eslint-plugin-svelte": "^2.46.0", - "eslint-plugin-tailwindcss": "^3.17.5", - "prettier-plugin-astro": "^0.14.1", - "prettier-plugin-packagejson": "^2.5.3", - "prettier-plugin-slidev": "^1.0.5", - "prettier-plugin-tailwindcss": "^0.6.8", - "svelte-eslint-parser": "^0.43.0" + "simple-git-hooks": { + "pre-commit": "npx lint-staged" }, - "peerDependenciesMeta": { - "@eslint-react/eslint-plugin": { - "optional": true - }, - "@next/eslint-plugin-next": { - "optional": true - }, - "@prettier/plugin-xml": { - "optional": true - }, - "@stylistic/eslint-plugin-js": { - "optional": true - }, - "@stylistic/eslint-plugin-jsx": { - "optional": true - }, - "@tanstack/eslint-plugin-query": { - "optional": true - }, - "@trivago/prettier-plugin-sort-imports": { - "optional": true - }, - "@unocss/eslint-plugin": { - "optional": true - }, - "astro-eslint-parser": { - "optional": true - }, - "eslint-plugin-astro": { - "optional": true - }, - "eslint-plugin-format": { - "optional": true - }, - "eslint-plugin-react": { - "optional": true - }, - "eslint-plugin-react-hooks": { - "optional": true - }, - "eslint-plugin-react-refresh": { - "optional": true - }, - "eslint-plugin-security": { - "optional": true - }, - "eslint-plugin-solid": { - "optional": true - }, - "eslint-plugin-svelte": { - "optional": true - }, - "eslint-plugin-tailwindcss": { - "optional": true - }, - "prettier-plugin-astro": { - "optional": true - }, - "prettier-plugin-packagejson": { - "optional": true - }, - "prettier-plugin-slidev": { - "optional": true - }, - "prettier-plugin-tailwindcss": { - "optional": true - }, - "svelte-eslint-parser": { - "optional": true - } + "lint-staged": { + "*": "eslint --fix" + }, + "resolutions": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/utils": "^8.10.0", + "eslint": "^9.13.0", + "tsx": "^4.19.1" }, "dependencies": { "@antfu/install-pkg": "^1.0.0", @@ -149,7 +69,7 @@ "eslint-plugin-array-func": "^5.0.2", "eslint-plugin-clsx": "^0.0.10", "eslint-plugin-command": "^3.1.0", - "eslint-plugin-default-import-name": "^0.2.0", + "eslint-plugin-default-import-name": "^0.3.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-expect-type": "^0.6.2", "eslint-plugin-github": "^5.1.8", @@ -241,16 +161,101 @@ "vitest": "^3.0.6", "vue": "^3.5.13" }, - "resolutions": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/utils": "^8.10.0", + "peerDependencies": { + "@eslint-react/eslint-plugin": "^1.15.0", + "@prettier/plugin-xml": "^3.4.1", + "@tanstack/eslint-plugin-query": "^5.66.1", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", + "@unocss/eslint-plugin": "^0.63.4", + "astro-eslint-parser": "^1.0.3", "eslint": "^9.13.0", - "tsx": "^4.19.1" + "eslint-plugin-astro": "^1.3.0", + "eslint-plugin-format": "^0.1.2", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.13", + "eslint-plugin-solid": "^0.14.3", + "eslint-plugin-storybook": "^0.11.3", + "eslint-plugin-svelte": "^2.46.0", + "eslint-plugin-tailwindcss": "^3.17.5", + "prettier-plugin-astro": "^0.14.1", + "prettier-plugin-packagejson": "^2.5.3", + "prettier-plugin-slidev": "^1.0.5", + "prettier-plugin-tailwindcss": "^0.6.8", + "svelte-eslint-parser": "^0.43.0" }, - "simple-git-hooks": { - "pre-commit": "npx lint-staged" + "peerDependenciesMeta": { + "@eslint-react/eslint-plugin": { + "optional": true + }, + "@next/eslint-plugin-next": { + "optional": true + }, + "@prettier/plugin-xml": { + "optional": true + }, + "@stylistic/eslint-plugin-js": { + "optional": true + }, + "@stylistic/eslint-plugin-jsx": { + "optional": true + }, + "@tanstack/eslint-plugin-query": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@unocss/eslint-plugin": { + "optional": true + }, + "astro-eslint-parser": { + "optional": true + }, + "eslint-plugin-astro": { + "optional": true + }, + "eslint-plugin-format": { + "optional": true + }, + "eslint-plugin-react": { + "optional": true + }, + "eslint-plugin-react-hooks": { + "optional": true + }, + "eslint-plugin-react-refresh": { + "optional": true + }, + "eslint-plugin-security": { + "optional": true + }, + "eslint-plugin-solid": { + "optional": true + }, + "eslint-plugin-storybook": { + "optional": true + }, + "eslint-plugin-svelte": { + "optional": true + }, + "eslint-plugin-tailwindcss": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-packagejson": { + "optional": true + }, + "prettier-plugin-slidev": { + "optional": true + }, + "prettier-plugin-tailwindcss": { + "optional": true + }, + "svelte-eslint-parser": { + "optional": true + } }, - "lint-staged": { - "*": "eslint --fix" - } -} \ No newline at end of file + "packageManager": "pnpm@10.4.1" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b7f7d50bc..93fabbae8c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,8 +75,8 @@ importers: specifier: ^3.1.0 version: 3.1.0(eslint@9.21.0(jiti@2.4.2)) eslint-plugin-default-import-name: - specifier: ^0.2.0 - version: 0.2.0(eslint@9.21.0(jiti@2.4.2)) + specifier: ^0.3.0 + version: 0.3.0(eslint@9.21.0(jiti@2.4.2)) eslint-plugin-eslint-comments: specifier: ^3.2.0 version: 3.2.0(eslint@9.21.0(jiti@2.4.2)) @@ -1967,8 +1967,8 @@ packages: peerDependencies: eslint: ^9.13.0 - eslint-plugin-default-import-name@0.2.0: - resolution: {integrity: sha512-oL9rXT3MLsjY6x2dZ51/u7mDi0vsDELzIkS3jvlk2IemMmEKKfLU6Z5HXX7XFMifFQ6kuKK4F+uqN1r1HxZ1Mw==} + eslint-plugin-default-import-name@0.3.0: + resolution: {integrity: sha512-hROvgzUG/k3VnvYtRddTBnCOj5Cl2js7g0/BR3WUJGyyzsh15dPL9MxCo6X469/om0LiVOGuQDeulW3XanHPGA==} peerDependencies: eslint: ^9.13.0 @@ -6230,7 +6230,7 @@ snapshots: '@es-joy/jsdoccomment': 0.50.0 eslint: 9.21.0(jiti@2.4.2) - eslint-plugin-default-import-name@0.2.0(eslint@9.21.0(jiti@2.4.2)): + eslint-plugin-default-import-name@0.3.0(eslint@9.21.0(jiti@2.4.2)): dependencies: eslint: 9.21.0(jiti@2.4.2) scule: 1.3.0 diff --git a/scripts/typegen.ts b/scripts/typegen.ts index b2a0e14925..913aa2eef5 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -18,6 +18,7 @@ import { node, perfectionist, prettier, + query, react, regexp, security, @@ -67,6 +68,7 @@ const configs = await combine( solid(), sortPackageJson(), storybook(), + query(), stylistic(), svelte(), tailwindcss(), diff --git a/src/cli.ts b/src/cli.ts index 898cb5da11..35078440d9 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1 +1 @@ -export * from "./cli/index"; +export type * from "./cli/index"; diff --git a/src/cli/constants.ts b/src/cli/constants.ts index 58fe0ed21e..4500bc8478 100644 --- a/src/cli/constants.ts +++ b/src/cli/constants.ts @@ -89,9 +89,9 @@ export const frameworks: Array = frameworkOptions.map( export const extraOptions: Array> = [ { - hint: "Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)", label: c.red("Formatter"), value: "formatter", + hint: "Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)", }, { label: c.cyan("UnoCSS"), diff --git a/src/cli/index.ts b/src/cli/index.ts index 0b23b2e553..bcf488c2ce 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -55,4 +55,4 @@ const instance = yargs(hideBin(process.argv)) .version("version", pkgJson.version) .alias("v", "version"); -instance.help().argv; +void instance.help().argv; diff --git a/src/cli/run.ts b/src/cli/run.ts index 5d239ccb22..dcfc97d29a 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -46,25 +46,25 @@ export async function run(options: CliRunOptions = {}) { // Set default value for promptResult if `argSkipPrompt` is enabled let result: PromptResult = { - extra: argExtra ?? [], - frameworks: argTemplate ?? [], uncommittedConfirmed: false, + frameworks: argTemplate ?? [], + extra: argExtra ?? [], updateVscodeSettings: true, }; if (!argSkipPrompt) { result = (await p.group( { - uncommittedConfirmed: () => { - if (argSkipPrompt || isGitClean()) return Promise.resolve(true); + uncommittedConfirmed: async () => { + if (argSkipPrompt || isGitClean()) return true; - return p.confirm({ + return await p.confirm({ initialValue: false, message: "There are uncommitted changes in the current repository, are you sure to continue?", }); }, - frameworks: ({ results }) => { + frameworks: async ({ results }) => { const isArgTemplateValid = typeof argTemplate === "string" && Boolean(frameworks.includes(argTemplate as FrameworkOption)); @@ -76,18 +76,16 @@ export async function run(options: CliRunOptions = {}) { ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:"; - return p.multiselect({ + return await p.multiselect({ message: c.reset(message), options: frameworkOptions, required: false, }); }, - extra: ({ results }) => { + extra: async ({ results }) => { const isArgExtraValid = - argExtra?.length && - argExtra.filter( - (element) => !extra.includes(element as ExtraLibrariesOption), - ).length === 0; + argExtra.length > 0 && + argExtra.filter((element) => !extra.includes(element)).length === 0; if (!results.uncommittedConfirmed || isArgExtraValid) return; @@ -96,17 +94,17 @@ export async function run(options: CliRunOptions = {}) { ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:"; - return p.multiselect({ + return await p.multiselect({ message: c.reset(message), options: extraOptions, required: false, }); }, - updateVscodeSettings: ({ results }) => { + updateVscodeSettings: async ({ results }) => { if (!results.uncommittedConfirmed) return; - return p.confirm({ + return await p.confirm({ initialValue: true, message: "Update .vscode/settings.json for better VS Code experience?", diff --git a/src/cli/stages/update-eslint-files.ts b/src/cli/stages/update-eslint-files.ts index d0ecf5075a..c5181f15b3 100644 --- a/src/cli/stages/update-eslint-files.ts +++ b/src/cli/stages/update-eslint-files.ts @@ -62,13 +62,13 @@ export async function updateEslintFiles(result: PromptResult) { const files = fs.readdirSync(cwd); const legacyConfig: Array = []; for (const file of files) { - if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) + if (/eslint|prettier/.test(file) && !file.includes('eslint.config.')) legacyConfig.push(file); } if (legacyConfig.length > 0) p.note( - `${c.dim(legacyConfig.join(", "))}`, + c.dim(legacyConfig.join(", ")), "You can now remove those files manually", ); } diff --git a/src/cli/stages/update-package-json.ts b/src/cli/stages/update-package-json.ts index 08d887e340..096b1b0f6f 100644 --- a/src/cli/stages/update-package-json.ts +++ b/src/cli/stages/update-package-json.ts @@ -61,7 +61,7 @@ export async function updatePackageJson(result: PromptResult) { } if (addedPackages.length > 0) - p.note(`${c.dim(addedPackages.join(", "))}`, "Added packages"); + p.note(c.dim(addedPackages.join(", ")), "Added packages"); await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2)); p.log.success(c.green(`Changes wrote to package.json`)); diff --git a/src/configs/astro.ts b/src/configs/astro.ts index 5e3c9d9de6..fc620b7467 100644 --- a/src/configs/astro.ts +++ b/src/configs/astro.ts @@ -11,10 +11,9 @@ export async function astro( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise> { const { - files = [GLOB_ASTRO], overrides = {}, - stylistic = false, + files = [GLOB_ASTRO], } = options; await ensurePackages(["eslint-plugin-astro"]); diff --git a/src/configs/i18n.ts b/src/configs/i18n.ts index dd8833508e..6c84d9b8e0 100644 --- a/src/configs/i18n.ts +++ b/src/configs/i18n.ts @@ -2,24 +2,25 @@ import { fixupConfigRules } from "@eslint/compat"; import path from "node:path"; import { compat } from "../compat"; import type { TypedFlatConfigItem } from "../types"; -import { ensurePackages } from "../utils"; +import { ensurePackages, interopDefault } from "../utils"; export async function i18n(): Promise> { await ensurePackages([ "eslint-plugin-i18n-checker", "eslint-plugin-i18n-json", "eslint-plugin-i18n-prefix", - "eslint-plugin-i18next", "@naturacosmeticos/eslint-plugin-i18n-checker", ]); + const [i18next] = await Promise.all([ + interopDefault(import("eslint-plugin-i18next")), + ] as const); + return [ + i18next.configs["flat/recommended"], ...fixupConfigRules( compat.config({ - extends: [ - "plugin:i18n-prefix/recommended", - "plugin:i18next/recommended", - ], + extends: ["plugin:i18next/recommended"], plugins: ["@naturacosmeticos/i18n-checker"], rules: { /** @@ -66,5 +67,12 @@ export async function i18n(): Promise> { ], }), ), + { + name: "nirtamir2/i18n/storybook", + files: ["**.stories.tsx"], + rules: { + "i18next/no-string-literal": "off", + }, + }, ]; } diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts index 3d6aa1ff16..89ba07643a 100644 --- a/src/configs/javascript.ts +++ b/src/configs/javascript.ts @@ -1,4 +1,5 @@ import { fixupConfigRules } from "@eslint/compat"; +import github from "eslint-plugin-github"; import sonarjs from "eslint-plugin-sonarjs"; import globals from "globals"; import { compat } from "../compat"; @@ -105,33 +106,29 @@ export async function javascript( rules: { "array-func/prefer-array-from": 0, // conflicts with unicorn/prefer-spread }, + }, { + name: "nirtamir2/javascript/github", + rules: { + "github/array-foreach": 2, + "github/async-currenttarget": 2, + "github/async-preventdefault": 2, + "github/authenticity-token": 2, + "github/get-attribute": 2, + "github/js-class-name": 2, + "github/no-blur": 2, + "github/no-d-none": 2, + "github/no-dataset": 2, + "github/no-implicit-buggy-globals": 2, + "github/no-inner-html": 2, + "github/no-innerText": 2, + "github/no-dynamic-script-tag": 2, + "github/no-then": 2, + "github/no-useless-passive": 2, + "github/prefer-observers": 2, + "github/require-passive-events": 2, + "github/unescaped-html-literal": 2, + }, }, - ...fixupConfigRules( - compat.config({ - plugins: ["github"], - rules: { - "github/a11y-no-generic-link-text": 2, - "github/array-foreach": 2, - "github/async-currenttarget": 2, - "github/async-preventdefault": 2, - "github/authenticity-token": 2, - "github/get-attribute": 2, - "github/js-class-name": 2, - "github/no-blur": 2, - "github/no-d-none": 2, - "github/no-dataset": 2, - "github/no-implicit-buggy-globals": 2, - "github/no-inner-html": 2, - "github/no-innerText": 2, - "github/no-dynamic-script-tag": 2, - "github/no-then": 2, - "github/no-useless-passive": 2, - "github/prefer-observers": 2, - "github/require-passive-events": 2, - "github/unescaped-html-literal": 2, - }, - }), - ), { files: [".prettierrc.mjs"], rules: { @@ -168,6 +165,7 @@ export async function javascript( plugins: { antfu: pluginAntfu, "unused-imports": pluginUnusedImports, + "github": github, }, rules: { "accessor-pairs": [ @@ -414,6 +412,8 @@ export async function javascript( { name: "nirtami2/javascript/sonar/disables", rules: { + "sonarjs/prefer-read-only-props": "off", + "sonarjs/deprecation": "off", // I have it in @typescript-eslint/no-deprecated "sonarjs/new-cap": "off", // sometimes I want api.GET() "sonarjs/todo-tag": "off", // somtimes I want TODO: stuff diff --git a/src/configs/jsonc.ts b/src/configs/jsonc.ts index e359c33573..3ce83812b1 100644 --- a/src/configs/jsonc.ts +++ b/src/configs/jsonc.ts @@ -12,8 +12,8 @@ export async function jsonc( ): Promise> { const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], - overrides = {}, stylistic = false, + overrides = {}, } = options; const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic; diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts index a872be106d..eae935a2a0 100644 --- a/src/configs/markdown.ts +++ b/src/configs/markdown.ts @@ -16,8 +16,8 @@ export async function markdown( options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {}, ): Promise> { const { - componentExts = [], files = [GLOB_MARKDOWN], + componentExts = [], overrides = {}, } = options; diff --git a/src/configs/query.ts b/src/configs/query.ts index ad85991123..b262926530 100644 --- a/src/configs/query.ts +++ b/src/configs/query.ts @@ -4,9 +4,17 @@ import { ensurePackages, interopDefault } from "../utils"; export async function query(): Promise> { await ensurePackages(["@tanstack/eslint-plugin-query"]); - const [pluginTanstackQuery] = await Promise.all([ - interopDefault(import("@tanstack/eslint-plugin-query")), - ] as const); + const pluginTanstackQuery = await interopDefault( + import("@tanstack/eslint-plugin-query"), + ); - return pluginTanstackQuery.configs["flat/recommended"]; + return [ + { + name: "@nirtamir2/query", + plugins: { + "@tanstack/query": pluginTanstackQuery, + }, + }, + ...pluginTanstackQuery.configs["flat/recommended"], + ]; } diff --git a/src/configs/react.ts b/src/configs/react.ts index 9b05bf735f..a4e00ef7aa 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -24,7 +24,7 @@ const NextJsPackages = ["next"]; export async function react( options: OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles = {}, ): Promise> { - const { files = [GLOB_SRC], overrides = {} } = options; + const { overrides = {}, files = [GLOB_SRC] } = options; await ensurePackages([ "@eslint-react/eslint-plugin", @@ -39,7 +39,7 @@ export async function react( await ensurePackages(["@next/eslint-plugin-next"]); } - const tsconfigPath = options?.tsconfigPath + const tsconfigPath = options.tsconfigPath ? toArray(options.tsconfigPath) : undefined; const isTypeAware = Boolean(tsconfigPath); diff --git a/src/configs/solid.ts b/src/configs/solid.ts index 7ea8a5737b..f200f367e5 100644 --- a/src/configs/solid.ts +++ b/src/configs/solid.ts @@ -17,14 +17,14 @@ export async function solid( OptionsTypeScriptWithTypes = {}, ): Promise> { const { - files = [GLOB_JSX, GLOB_TSX], - overrides = {}, typescript = true, + overrides = {}, + files = [GLOB_JSX, GLOB_TSX], } = options; await ensurePackages(["eslint-plugin-solid"]); - const tsconfigPath = options?.tsconfigPath + const tsconfigPath = options.tsconfigPath ? toArray(options.tsconfigPath) : undefined; const isTypeAware = Boolean(tsconfigPath); diff --git a/src/configs/storybook.ts b/src/configs/storybook.ts index e3b26763c9..5aaa635411 100644 --- a/src/configs/storybook.ts +++ b/src/configs/storybook.ts @@ -1,29 +1,26 @@ -import { fixupConfigRules } from "@eslint/compat"; -import { compat } from "../compat"; import type { TypedFlatConfigItem } from "../types"; -import { ensurePackages } from "../utils"; +import { ensurePackages, interopDefault } from "../utils"; export async function storybook(): Promise> { await ensurePackages(["eslint-plugin-storybook"]); + const storybookPlugin = await interopDefault( + import("eslint-plugin-storybook"), + ); + return [ - ...fixupConfigRules( - compat.config({ - extends: [ - "plugin:storybook/recommended", - "plugin:storybook/csf-strict", - "plugin:storybook/addon-interactions", - ], - // .eslintignore is not supported with flat config, make sure to ignore also other build and test folders - ignorePatterns: ["!.storybook", "storybook-static"], - }), - ), { - name: "nirtamir2/storybook/i18n", - files: ["**.stories.tsx"], - rules: { - "i18next/no-string-literal": "off", + name: "nirtamir2/storybook/init", + plugins: { + storybook: storybookPlugin, }, }, + { + name: "nirtamir2/storybook/ignore-patterns", + ignores: ["!.storybook", "storybook-static"], + }, + ...storybookPlugin.configs["flat/recommended"], + ...storybookPlugin.configs["flat/csf-strict"], + ...storybookPlugin.configs["flat/addon-interactions"], ]; } diff --git a/src/configs/stylistic.ts b/src/configs/stylistic.ts index 9364d1c5fc..2aaf6f65ab 100644 --- a/src/configs/stylistic.ts +++ b/src/configs/stylistic.ts @@ -8,8 +8,8 @@ import { interopDefault } from "../utils"; export const StylisticConfigDefaults: StylisticConfig = { indent: 2, - jsx: true, quotes: "double", + jsx: true, semi: true, }; @@ -21,12 +21,12 @@ export async function stylistic( options: StylisticOptions = {}, ): Promise> { const { - indent, - jsx, lessOpinionated = false, - overrides = {}, + indent, quotes, + jsx, semi, + overrides = {}, } = { ...StylisticConfigDefaults, ...options, diff --git a/src/configs/svelte.ts b/src/configs/svelte.ts index d7ccdd9621..69b49faa4a 100644 --- a/src/configs/svelte.ts +++ b/src/configs/svelte.ts @@ -14,7 +14,7 @@ export async function svelte( OptionsStylistic & OptionsFiles = {}, ): Promise> { - const { files = [GLOB_SVELTE], overrides = {}, stylistic = false } = options; + const { overrides = {}, stylistic = false, files = [GLOB_SVELTE] } = options; const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic; diff --git a/src/configs/toml.ts b/src/configs/toml.ts index 3f32cfb3ca..77056e3cc5 100644 --- a/src/configs/toml.ts +++ b/src/configs/toml.ts @@ -10,7 +10,7 @@ import { interopDefault } from "../utils"; export async function toml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise> { - const { files = [GLOB_TOML], overrides = {}, stylistic = false } = options; + const { overrides = {}, stylistic = false, files = [GLOB_TOML] } = options; const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic; diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 23c112f086..3a69ac0c68 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,26 +1,33 @@ import expectType from "eslint-plugin-expect-type/configs/recommended"; -import tseslint from "typescript-eslint"; -import { GLOB_ASTRO_TS, GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../globs"; import sortDestructureKeysTypescriptConfig from "eslint-plugin-sort-destructure-keys-typescript/config"; +import { GLOB_ASTRO_TS, GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../globs"; import { pluginAntfu } from "../plugins"; import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, + OptionsProjectType, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem, } from "../types"; -import { interopDefault, toArray } from "../utils"; +import { interopDefault } from "../utils"; export async function typescript( options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & - OptionsTypeScriptParserOptions = {}, + OptionsTypeScriptParserOptions & + OptionsProjectType = {}, ): Promise> { - const { componentExts = [], overrides = {}, parserOptions = {} } = options; + const { + componentExts = [], + overrides = {}, + overridesTypeAware = {}, + parserOptions = {}, + type = "app", + } = options; const files = options.files ?? [ GLOB_TS, @@ -33,16 +40,13 @@ export async function typescript( `${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS, ]; - const tsconfigPath = options?.tsconfigPath - ? toArray(options.tsconfigPath) - : undefined; - const isTypeAware = Boolean(tsconfigPath); + const tsconfigPath = + options?.tsconfigPath == null ? undefined : options.tsconfigPath; + const isTypeAware = tsconfigPath != null; const typeAwareRules: TypedFlatConfigItem["rules"] = { "dot-notation": "off", "no-implied-eval": "off", - "no-throw-literal": "off", - "sort-destructure-keys-typescript/sort-destructure-keys-by-type": "error", "@typescript-eslint/await-thenable": "error", "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }], "@typescript-eslint/no-floating-promises": "error", @@ -55,11 +59,14 @@ export async function typescript( "@typescript-eslint/no-unsafe-call": "error", "@typescript-eslint/no-unsafe-member-access": "error", "@typescript-eslint/no-unsafe-return": "error", - "@typescript-eslint/restrict-plus-operands": "error", "@typescript-eslint/promise-function-async": "error", + "@typescript-eslint/restrict-plus-operands": "error", "@typescript-eslint/restrict-template-expressions": "error", - "@typescript-eslint/return-await": "error", - "@typescript-eslint/strict-boolean-expressions": "error", + "@typescript-eslint/return-await": ["error", "in-try-catch"], + "@typescript-eslint/strict-boolean-expressions": [ + "error", + { allowNullableBoolean: true, allowNullableObject: true }, + ], "@typescript-eslint/switch-exhaustiveness-check": "error", "@typescript-eslint/unbound-method": "error", }; @@ -91,7 +98,7 @@ export async function typescript( tsconfigRootDir: process.cwd(), } : {}), - ...(parserOptions as any), + ...parserOptions, }, }, name: `antfu/typescript/${typeAware ? "type-aware-parser" : "parser"}`, @@ -104,38 +111,28 @@ export async function typescript( name: "antfu/typescript/setup", plugins: { antfu: pluginAntfu, - // "@typescript-eslint": pluginTs as any, + "@typescript-eslint": pluginTs, }, }, // assign type-aware parser for type-aware files and type-unaware parser for the rest ...(isTypeAware ? [ + makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware), - makeParser(false, files, filesTypeAware), ] : [makeParser(false, files)]), - ...tseslint.configs.strict, - ...(isTypeAware ? tseslint.configs.strictTypeChecked : []), { files, name: "antfu/typescript/rules", rules: { - ...pluginTs.configs["eslint-recommended"].overrides![0].rules, ...pluginTs.configs.strict.rules, "no-dupe-class-members": "off", - "no-loss-of-precision": "off", "no-redeclare": "off", "no-use-before-define": "off", "no-useless-constructor": "off", "@typescript-eslint/ban-ts-comment": [ "error", - { - "ts-expect-error": "allow-with-description", - "ts-ignore": true, - "ts-nocheck": true, - "ts-check": false, - minimumDescriptionLength: 3, - }, + { "ts-expect-error": "allow-with-description" }, ], "@typescript-eslint/consistent-type-definitions": [ "error", @@ -149,16 +146,29 @@ export async function typescript( prefer: "type-imports", }, ], + "@typescript-eslint/method-signature-style": ["error", "property"], // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful "@typescript-eslint/no-dupe-class-members": "error", "@typescript-eslint/no-dynamic-delete": "off", + "@typescript-eslint/no-empty-object-type": [ + "error", + { allowInterfaces: "always" }, + ], "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extraneous-class": "off", "@typescript-eslint/no-import-type-side-effects": "error", "@typescript-eslint/no-invalid-void-type": "off", "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-redeclare": "error", + "@typescript-eslint/no-redeclare": ["error", { builtinGlobals: false }], "@typescript-eslint/no-require-imports": "error", + "@typescript-eslint/no-unused-expressions": [ + "error", + { + allowShortCircuit: true, + allowTaggedTemplates: true, + allowTernary: true, + }, + ], "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-use-before-define": [ "error", @@ -168,18 +178,43 @@ export async function typescript( "@typescript-eslint/no-wrapper-object-types": "error", "@typescript-eslint/triple-slash-reference": "off", "@typescript-eslint/unified-signatures": "off", + + ...(type === "lib" + ? { + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + allowExpressions: true, + allowHigherOrderFunctions: true, + allowIIFEs: true, + }, + ], + } + : {}), + ...overrides, }, }, ...(isTypeAware ? [ - sortDestructureKeysTypescriptConfig(), + { + files: filesTypeAware, + ignores: ignoresTypeAware, + rules: { + ...pluginTs.configs["strict-type-checked"].rules, + }, + }, + { + files: filesTypeAware, + ignores: ignoresTypeAware, + ...sortDestructureKeysTypescriptConfig(), + }, { files: filesTypeAware, ignores: ignoresTypeAware, name: "antfu/typescript/rules-type-aware", rules: { - ...(tsconfigPath ? typeAwareRules : {}), - ...overrides, + ...typeAwareRules, + ...overridesTypeAware, }, }, ] @@ -217,6 +252,7 @@ export async function typescript( } : [], { + name: "nirtamir-typescript-rules", files, ignores: [".storybook/**"], rules: { @@ -475,9 +511,9 @@ export async function typescript( // #endregion "array-callback-return": "off", // https://github.com/typescript-eslint/typescript-eslint/issues/2841 - false positive with TypeScript + ...(isTypeAware ? {} : pluginTs.configs["disable-type-checked"].rules), }, }, - isTypeAware ? [] : tseslint.configs.disableTypeChecked, { name: "nirtamir2/typescript/overrides", files, diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts index c7251430f7..cd8db47f04 100644 --- a/src/configs/unicorn.ts +++ b/src/configs/unicorn.ts @@ -34,8 +34,6 @@ export async function unicorn(): Promise> { "unicorn/error-message": "error", // Uppercase regex escapes "unicorn/escape-case": "error", - // Array.isArray instead of instanceof - "unicorn/no-instanceof-array": "error", // Ban `new Array` as `Array` constructor's params are ambiguous "unicorn/no-new-array": "error", // Prevent deprecated `new Buffer()` diff --git a/src/configs/vue.ts b/src/configs/vue.ts index 665dd8b70f..3a626ebd12 100644 --- a/src/configs/vue.ts +++ b/src/configs/vue.ts @@ -18,10 +18,10 @@ export async function vue( OptionsFiles = {}, ): Promise> { const { - files = [GLOB_VUE], + vueVersion = 3, overrides = {}, stylistic = false, - vueVersion = 3, + files = [GLOB_VUE], } = options; const sfcBlocks = options.sfcBlocks === true ? {} : (options.sfcBlocks ?? {}); diff --git a/src/configs/yaml.ts b/src/configs/yaml.ts index def19ca8b6..eef0596ead 100644 --- a/src/configs/yaml.ts +++ b/src/configs/yaml.ts @@ -10,7 +10,7 @@ import { interopDefault } from "../utils"; export async function yaml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise> { - const { files = [GLOB_YAML], overrides = {}, stylistic = false } = options; + const { overrides = {}, stylistic = false, files = [GLOB_YAML] } = options; const { indent = 2, quotes = "single" } = typeof stylistic === "boolean" ? {} : stylistic; diff --git a/src/factory.ts b/src/factory.ts index f77411501c..46f49cbdb6 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -79,20 +79,6 @@ const StorybookPackages = [ "@storybook/test", ]; -export const defaultPluginRenaming = { - "@eslint-react": "react", - "@eslint-react/dom": "react-dom", - "@eslint-react/hooks-extra": "react-hooks-extra", - "@eslint-react/naming-convention": "react-naming-convention", - - "@stylistic": "style", - "@typescript-eslint": "ts", - "import-x": "import", - n: "node", - vitest: "test", - yml: "yaml", -}; - /** * Construct an array of ESLint flat config items. * @param {OptionsConfig & TypedFlatConfigItem} options @@ -387,10 +373,13 @@ export function nirtamir2( // User can optionally pass a flat config item to the first argument // We pick the known keys as ESLint would do schema validation - const fusedConfig = flatConfigProps.reduce((acc, key) => { - if (key in options) acc[key] = options[key] as any; - return acc; - }, {} as TypedFlatConfigItem); + const fusedConfig = flatConfigProps.reduce( + (acc, key) => { + if (key in options) acc[key] = options[key] as never; + return acc; + }, + {}, + ); if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]); let composer = new FlatConfigComposer(); diff --git a/src/index.ts b/src/index.ts index 72a574c5ee..956de85711 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ export * from "./configs"; export * from "./factory"; export * from "./globs"; -export * from "./types"; +export type * from "./types"; export * from "./utils"; export { nirtamir2 as default } from "./factory"; diff --git a/src/plugins.ts b/src/plugins.ts index 72d749e625..6de51211f9 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -3,7 +3,7 @@ export { default as pluginAntfu } from "eslint-plugin-antfu"; export { default as pluginComments } from "eslint-plugin-eslint-comments"; -export * as pluginImport from "eslint-plugin-import-x"; +export { default as pluginImport } from "eslint-plugin-import-x"; export { default as pluginNode } from "eslint-plugin-n"; export { default as pluginUnicorn } from "eslint-plugin-unicorn"; export { default as pluginUnusedImports } from "eslint-plugin-unused-imports"; diff --git a/src/stub.d.ts b/src/stub.d.ts index 8de32c60a8..b3964df2f3 100644 --- a/src/stub.d.ts +++ b/src/stub.d.ts @@ -1,3 +1,4 @@ declare module "eslint-plugin-react-hooks"; +declare module "eslint-plugin-github"; declare module "eslint-plugin-react-refresh"; declare module "eslint-plugin-tailwindcss"; diff --git a/src/types.ts b/src/types.ts index bb4940e539..21aca3423e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,6 +17,7 @@ export type TypedFlatConfigItem = Omit< // Relax plugins type limitation, as most of the plugins did not have correct type info yet. /** * An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files. + * * @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration) */ plugins?: Record; @@ -32,6 +33,7 @@ export interface OptionsFiles { export interface OptionsVue extends OptionsOverrides { /** * Create virtual files for Vue SFC blocks to enable linting. + * * @see https://github.com/antfu/eslint-processor-vue-blocks * @default true */ @@ -39,6 +41,7 @@ export interface OptionsVue extends OptionsOverrides { /** * Vue version. Apply different rules set from `eslint-plugin-vue`. + * * @default 3 */ vueVersion?: 2 | 3; @@ -70,6 +73,13 @@ export interface OptionsFormatters { */ xml?: "prettier" | boolean; + /** + * Enable formatting support for SVG. + * + * Currently only support Prettier. + */ + svg?: "prettier" | boolean; + tailwindcss?: "prettier" | boolean; /** @@ -122,12 +132,22 @@ export interface OptionsFormatters { export interface OptionsComponentExts { /** * Additional extensions for components. + * * @example ['vue'] * @default [] */ componentExts?: Array; } +export interface OptionsUnicorn { + /** + * Include all rules recommended by `eslint-plugin-unicorn`, instead of only ones picked by Anthony. + * + * @default false + */ + allRecommended?: boolean; +} + export interface OptionsTypeScriptParserOptions { /** * Additional parser options for TypeScript. @@ -153,6 +173,11 @@ export interface OptionsTypeScriptWithTypes { * @see https://typescript-eslint.io/linting/typed-linting/ */ tsconfigPath?: string; + + /** + * Override type aware rules. + */ + overridesTypeAware?: TypedFlatConfigItem["rules"]; } export interface OptionsHasTypeScript { @@ -163,15 +188,25 @@ export interface OptionsStylistic { stylistic?: boolean | StylisticConfig; } -export type StylisticConfig = Pick< - StylisticCustomizeOptions, - "indent" | "quotes" | "jsx" | "semi" ->; +export interface StylisticConfig + extends Pick< + StylisticCustomizeOptions, + "indent" | "quotes" | "jsx" | "semi" + > {} export interface OptionsOverrides { overrides?: TypedFlatConfigItem["rules"]; } +export interface OptionsProjectType { + /** + * Type of the project. `lib` will enable more strict rules for libraries. + * + * @default 'app' + */ + type?: "app" | "lib"; +} + export interface OptionsRegExp { /** * Override rulelevels @@ -196,11 +231,14 @@ export interface OptionsUnoCSS extends OptionsOverrides { strict?: boolean; } -export interface OptionsConfig extends OptionsComponentExts { +export interface OptionsConfig + extends OptionsComponentExts, + OptionsProjectType { /** * Enable gitignore support. * * Passing an object to configure the options. + * * @see https://github.com/antfu/eslint-config-flat-gitignore * @default true */ @@ -212,6 +250,7 @@ export interface OptionsConfig extends OptionsComponentExts { * Including: * - `antfu/top-level-function` * - `antfu/if-newline` + * * @default false */ lessOpinionated?: boolean; @@ -230,6 +269,7 @@ export interface OptionsConfig extends OptionsComponentExts { * Enable TypeScript support. * * Passing an object to enable TypeScript Language Server support. + * * @default auto-detect based on the dependencies */ typescript?: boolean | OptionsTypescript; @@ -238,18 +278,28 @@ export interface OptionsConfig extends OptionsComponentExts { * Enable JSX related rules. * * Currently only stylistic rules are included. + * * @default true */ jsx?: boolean; + /** + * Options for eslint-plugin-unicorn. + * + * @default true + */ + unicorn?: boolean | OptionsUnicorn; + /** * Enable test support. + * * @default true */ test?: boolean | OptionsOverrides; /** * Enable Vue support. + * * @default auto-detect based on the dependencies */ vue?: boolean | OptionsVue; @@ -262,6 +312,7 @@ export interface OptionsConfig extends OptionsComponentExts { /** * Enable JSONC support. + * * @default true */ jsonc?: boolean | OptionsOverrides; @@ -280,12 +331,14 @@ export interface OptionsConfig extends OptionsComponentExts { /** * Enable YAML support. + * * @default true */ yaml?: boolean | OptionsOverrides; /** * Enable TOML support. + * * @default true */ toml?: boolean | OptionsOverrides; @@ -298,6 +351,7 @@ export interface OptionsConfig extends OptionsComponentExts { * * Requires installing for formatting .astro: * - `prettier-plugin-astro` + * * @default false */ astro?: boolean | OptionsOverrides; @@ -306,12 +360,14 @@ export interface OptionsConfig extends OptionsComponentExts { * Enable linting for **code snippets** in Markdown. * * For formatting Markdown content, enable also `formatters.markdown`. + * * @default true */ markdown?: boolean | OptionsOverrides; /** * Enable stylistic rules. + * * @see https://eslint.style/ * @default true */ @@ -319,6 +375,7 @@ export interface OptionsConfig extends OptionsComponentExts { /** * Enable regexp rules. + * * @see https://ota-meshi.github.io/eslint-plugin-regexp/ * @default true */ @@ -331,6 +388,7 @@ export interface OptionsConfig extends OptionsComponentExts { * - `@eslint-react/eslint-plugin` * - `eslint-plugin-react-hooks` * - `eslint-plugin-react-refresh` + * * @default false */ react?: boolean | OptionsOverrides; @@ -339,6 +397,7 @@ export interface OptionsConfig extends OptionsComponentExts { * * Requires installing: * - `eslint-plugin-solid` + * * @default false */ solid?: boolean | OptionsOverrides; @@ -348,6 +407,7 @@ export interface OptionsConfig extends OptionsComponentExts { * * Requires installing: * - `eslint-plugin-svelte` + * * @default false */ svelte?: boolean; @@ -357,6 +417,7 @@ export interface OptionsConfig extends OptionsComponentExts { * * Requires installing: * - `@unocss/eslint-plugin` + * * @default false */ unocss?: boolean | OptionsUnoCSS; @@ -368,6 +429,7 @@ export interface OptionsConfig extends OptionsComponentExts { * - `eslint-plugin-format` * * When set to `true`, it will enable all formatters. + * * @default false */ formatters?: boolean | OptionsFormatters; @@ -387,6 +449,7 @@ export interface OptionsConfig extends OptionsComponentExts { /** * Provide overrides for rules for each integration. + * * @deprecated use `overrides` option in each integration key instead */ overrides?: { @@ -404,4 +467,4 @@ export interface OptionsConfig extends OptionsComponentExts { }; } -export { type ConfigNames } from "./typegen.d"; +export { type ConfigNames } from "./typegen"; diff --git a/src/utils.ts b/src/utils.ts index 16843bb93d..50a5a34b7d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -113,7 +113,7 @@ export async function interopDefault( } export async function ensurePackages(packages: Array) { - if (process.env.CI || process.stdout.isTTY === false) return; + if (process.env.CI || !process.stdout.isTTY) return; const nonExistingPackages = packages.filter( (i) => i && !isPackageExists(i), diff --git a/test/cli.spec.ts b/test/cli.spec.ts index 3b0bef2b11..86295d467a 100644 --- a/test/cli.spec.ts +++ b/test/cli.spec.ts @@ -19,7 +19,7 @@ async function run( NO_COLOR: "1", }, ) { - return execa("node", [CLI_PATH, ...params], { + return await execa("node", [CLI_PATH, ...params], { cwd: genPath, env: { ...process.env, @@ -34,15 +34,15 @@ async function createMockDir() { await Promise.all([ fs.writeFile(join(genPath, "package.json"), JSON.stringify({}, null, 2)), - fs.writeFile(join(genPath, ".eslintrc.yaml"), ""), + fs.writeFile(join(genPath, ".eslintrc.yml"), ""), fs.writeFile(join(genPath, ".eslintignore"), "some-path\nsome-file"), fs.writeFile(join(genPath, ".prettierc"), ""), fs.writeFile(join(genPath, ".prettierignore"), "some-path\nsome-file"), ]); } -beforeEach(async () => await createMockDir()); -afterAll(async () => await fs.rm(genPath, { recursive: true, force: true })); +beforeEach(async () => { await createMockDir(); }); +afterAll(async () => { await fs.rm(genPath, { recursive: true, force: true }); }); it("package.json updated", async () => { const { stdout } = await run(); @@ -57,7 +57,7 @@ it("package.json updated", async () => { expect(stdout).toContain("Changes wrote to package.json"); }); -it("esm eslint.config.ts", async () => { +it("esm eslint.config.js", async () => { const pkgContent = await fs.readFile("package.json", "utf8"); await fs.writeFile( join(genPath, "package.json"), @@ -67,32 +67,21 @@ it("esm eslint.config.ts", async () => { const { stdout } = await run(); const eslintConfigContent = await fs.readFile( - join(genPath, "eslint.config.ts"), + join(genPath, "eslint.config.js"), "utf8", ); expect(eslintConfigContent.includes("export default")).toBeTruthy(); - expect(stdout).toContain("Created eslint.config.ts"); + expect(stdout).toContain("Created eslint.config.js"); }); -it("cjs eslint.config.ts", async () => { - const { stdout } = await run(); - - const eslintConfigContent = await fs.readFile( - join(genPath, "eslint.config.ts"), - "utf8", - ); - expect(eslintConfigContent.includes("export default")).toBeTruthy(); - expect(stdout).toContain("Created eslint.config.ts"); -}); - -it("ignores files added in eslint.config.ts", async () => { +it("ignores files added in eslint.config.js", async () => { const { stdout } = await run(); const eslintConfigContent = ( - await fs.readFile(join(genPath, "eslint.config.ts"), "utf8") - ).replaceAll("\\", "/"); + await fs.readFile(join(genPath, "eslint.config.mjs"), "utf8") + ).replaceAll('\\', "/"); - expect(stdout).toContain("Created eslint.config.ts"); + expect(stdout).toContain("Created eslint.config.mjs"); expect(eslintConfigContent).toMatchInlineSnapshot(` "import nirtamir2 from '@nirtamir2/eslint-config' @@ -108,6 +97,6 @@ it("suggest remove unnecessary files", async () => { expect(stdout).toContain("You can now remove those files manually"); expect(stdout).toContain( - ".eslintignore, .eslintrc.yaml, .prettierc, .prettierignore", + ".eslintignore, .eslintrc.yml, .prettierc, .prettierignore", ); }); diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index 84e62c80c0..04aa4b6133 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -11,22 +11,24 @@ beforeAll(async () => { afterAll(async () => { await fs.rm("_fixtures", { recursive: true, force: true }); }); - -runWithConfig("js", { - typescript: false, - vue: false, -}); +// +// runWithConfig("js", { +// typescript: false, +// vue: false, +// }); runWithConfig("all", { - typescript: true, + typescript: { + tsconfigPath: "tsconfig.json" + }, vue: true, svelte: true, astro: true, }); -runWithConfig("no-style", { - typescript: true, - vue: true, - stylistic: false, -}); +// runWithConfig("no-style", { +// typescript: true, +// vue: true, +// stylistic: false, +// }); // runWithConfig( // "tab-double-quotes", // { @@ -44,21 +46,21 @@ runWithConfig("no-style", { // }, // ); -// https://github.com/nirtamir2/eslint-config/issues/255 -runWithConfig( - "ts-override", - { - typescript: true, - }, - { - rules: { - "@typescript-eslint/consistent-type-definitions": ["error", "type"], - "@typescript-eslint/explicit-member-accessibility": "warn", - "@typescript-eslint/parameter-properties": "warn", - "@typescript-eslint/no-explicit-any": "warn", - }, - }, -); +// https://github.com/antfu/eslint-config/issues/255 +// runWithConfig( +// "ts-override", +// { +// typescript: true, +// }, +// { +// rules: { +// "@typescript-eslint/consistent-type-definitions": ["error", "type"], +// "@typescript-eslint/explicit-member-accessibility": "warn", +// "@typescript-eslint/parameter-properties": "warn", +// "@typescript-eslint/no-explicit-any": "warn", +// }, +// }, +// ); // runWithConfig("with-formatters", { // typescript: true, @@ -106,7 +108,7 @@ export default nirtamir2( `, ); - await execa("npx", ["eslint", ".", "--fix"], { + await execa("npx", ["eslint", "--fix"], { cwd: target, stdio: "pipe", }); diff --git a/tsconfig.json b/tsconfig.json index 8d6be52cd2..92b45b6c46 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,10 +4,10 @@ "baseUrl": ".", "module": "ESNext", "moduleResolution": "Bundler", + "allowJs": true, "strict": true, "esModuleInterop": true, "skipLibCheck": true }, - "include": ["**/*.ts"], "exclude": ["./fixtures/**/*.*", "./_fixtures/**/*.*"] }