From 2f2e96f2759a62a8ffd1c5fff7c46e891f89e86e Mon Sep 17 00:00:00 2001 From: Joe Geary Date: Tue, 3 Dec 2024 10:17:25 -0500 Subject: [PATCH] Temporarily remove 3rd party rules and customize antfu defaults --- .github/renovate.json | 4 +- .vscode/settings.json | 92 +++++++++++----------- README.md | 118 ++++++++++++++-------------- eslint.config.ts | 10 +-- package.json | 158 ++++++++++++++++++------------------- src/config.ts | 70 +++++++++++------ src/configs/expo.ts | 22 ------ src/configs/javascript.ts | 32 -------- src/configs/react.ts | 18 ----- src/configs/sencha.ts | 21 ----- src/configs/typescript.ts | 26 ------- src/index.ts | 46 +++++++---- src/options.ts | 40 +++++----- src/types.d.ts | 18 ++--- test/fixtures.test.ts | 160 +++++++++++++++++++------------------- tsconfig.json | 28 +++---- tsup.config.ts | 4 +- 17 files changed, 390 insertions(+), 477 deletions(-) delete mode 100644 src/configs/expo.ts delete mode 100644 src/configs/javascript.ts delete mode 100644 src/configs/react.ts delete mode 100644 src/configs/sencha.ts delete mode 100644 src/configs/typescript.ts diff --git a/.github/renovate.json b/.github/renovate.json index 24ff39b..d20ed24 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,4 +1,4 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>oncoursesystems/renovate-config"] + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>oncoursesystems/renovate-config"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 91cdd7f..718140a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,53 +1,53 @@ { - // Auto fix - "editor.codeActionsOnSave": { - "source.fixAll.eslint": "explicit", - "source.organizeImports": "never" - }, - "editor.formatOnSave": false, + // Auto fix + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.organizeImports": "never" + }, + "editor.formatOnSave": false, - "eslint.options": { - "flags": ["unstable_ts_config"] - }, + "eslint.options": { + "flags": ["unstable_ts_config"] + }, - // Silent the stylistic rules in you IDE, but still auto fix them - "eslint.rules.customizations": [ - { "fixable": true, "rule": "style/*", "severity": "off" }, - { "fixable": true, "rule": "*-indent", "severity": "off" }, - { "fixable": true, "rule": "*-spacing", "severity": "off" }, - { "fixable": true, "rule": "*-spaces", "severity": "off" }, - { "fixable": true, "rule": "*-order", "severity": "off" }, - { "fixable": true, "rule": "*-dangle", "severity": "off" }, - { "fixable": true, "rule": "*-newline", "severity": "off" }, - { "fixable": true, "rule": "*quotes", "severity": "off" }, - { "fixable": true, "rule": "*semi", "severity": "off" } - ], - "eslint.runtime": "node", + // Silent the stylistic rules in you IDE, but still auto fix them + "eslint.rules.customizations": [ + { "fixable": true, "rule": "style/*", "severity": "off" }, + { "fixable": true, "rule": "*-indent", "severity": "off" }, + { "fixable": true, "rule": "*-spacing", "severity": "off" }, + { "fixable": true, "rule": "*-spaces", "severity": "off" }, + { "fixable": true, "rule": "*-order", "severity": "off" }, + { "fixable": true, "rule": "*-dangle", "severity": "off" }, + { "fixable": true, "rule": "*-newline", "severity": "off" }, + { "fixable": true, "rule": "*quotes", "severity": "off" }, + { "fixable": true, "rule": "*semi", "severity": "off" } + ], + "eslint.runtime": "node", - // Enable eslint for all supported languages - "eslint.validate": [ - "html", - "javascript", - "javascriptreact", - "json", - "json5", - "jsonc", - "markdown", - "toml", - "typescript", - "typescriptreact", - "vue", - "xml", - "yaml" - ], + // Enable eslint for all supported languages + "eslint.validate": [ + "html", + "javascript", + "javascriptreact", + "json", + "json5", + "jsonc", + "markdown", + "toml", + "typescript", + "typescriptreact", + "vue", + "xml", + "yaml" + ], - "pair-diff.patterns": [ - { - "source": "./fixtures/output/**/*.*", - "target": "./fixtures/input/" - } - ], - // Disable the default formatter, use eslint instead - "prettier.enable": false + "pair-diff.patterns": [ + { + "source": "./fixtures/output/**/*.*", + "target": "./fixtures/input/" + } + ], + // Disable the default formatter, use eslint instead + "prettier.enable": false } diff --git a/README.md b/README.md index a3a187a..f222cef 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,10 @@ For example: ```json { - "scripts": { - "lint": "eslint .", - "lint:fix": "eslint . --fix" - } + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint . --fix" + } } ``` @@ -54,47 +54,47 @@ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?it ```json { - // Disable the default formatter, use eslint instead - "prettier.enable": false, - "editor.formatOnSave": false, - - // Auto-fix on save - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true, - "source.organizeImports": true - }, - - // Silent the stylistic rules in your IDS, but still auto-fix them - "eslint.rules.customizations": [ - { "rule": "style/*", "severity": "off", "fixable": true }, - { "rule": "format/*", "severity": "off", "fixable": true }, - { "rule": "*-indent", "severity": "off", "fixable": true }, - { "rule": "*-spacing", "severity": "off", "fixable": true }, - { "rule": "*-spaces", "severity": "off", "fixable": true }, - { "rule": "*-order", "severity": "off", "fixable": true }, - { "rule": "*-dangle", "severity": "off", "fixable": true }, - { "rule": "*-newline", "severity": "off", "fixable": true }, - { "rule": "*quotes", "severity": "off", "fixable": true }, - { "rule": "*semi", "severity": "off", "fixable": true } - ], - - // Enable eslint for all supported languages - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "html", - "markdown", - "json", - "jsonc", - "yaml", - "toml", - "xml", - "css", - "less", - "scss" - ] + // Disable the default formatter, use eslint instead + "prettier.enable": false, + "editor.formatOnSave": false, + + // Auto-fix on save + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true, + "source.organizeImports": true + }, + + // Silent the stylistic rules in your IDS, but still auto-fix them + "eslint.rules.customizations": [ + { "rule": "style/*", "severity": "off", "fixable": true }, + { "rule": "format/*", "severity": "off", "fixable": true }, + { "rule": "*-indent", "severity": "off", "fixable": true }, + { "rule": "*-spacing", "severity": "off", "fixable": true }, + { "rule": "*-spaces", "severity": "off", "fixable": true }, + { "rule": "*-order", "severity": "off", "fixable": true }, + { "rule": "*-dangle", "severity": "off", "fixable": true }, + { "rule": "*-newline", "severity": "off", "fixable": true }, + { "rule": "*quotes", "severity": "off", "fixable": true }, + { "rule": "*semi", "severity": "off", "fixable": true } + ], + + // Enable eslint for all supported languages + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "html", + "markdown", + "json", + "jsonc", + "yaml", + "toml", + "xml", + "css", + "less", + "scss" + ] } ``` @@ -107,7 +107,7 @@ To enable React support, you need to explicitly turn it on: import oncourse from '@oncoursesystems/eslint-config'; export default oncourse({ - react: true, + react: true, }); ``` @@ -130,7 +130,7 @@ To enable Sencha ExtJS support, you need to explicitly turn it on: import oncourse from '@oncoursesystems/eslint-config'; export default oncourse({ - react: true, + react: true, }); ``` @@ -155,18 +155,18 @@ Example: import oncourse from '@oncoursesystems/eslint-config'; export default oncourse( - // Configure integrations here - { - formatters: false, - }, - // Any additional objects will be passed in as ESLint Flat Configs - // The files config is optional, but can be used to specify which files to lint - { - files: ['src/**/*.ts', 'src/**/*.tsx'], - rules: { - 'ts/typedef': 'off', - } - }, + // Configure integrations here + { + formatters: false, + }, + // Any additional objects will be passed in as ESLint Flat Configs + // The files config is optional, but can be used to specify which files to lint + { + files: ['src/**/*.ts', 'src/**/*.tsx'], + rules: { + 'ts/typedef': 'off', + } + }, ); ``` diff --git a/eslint.config.ts b/eslint.config.ts index 51fd1f8..568ab42 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,10 +1,10 @@ import oncourse from './src'; export default oncourse({ - type: 'lib', + type: 'lib', }, { - ignores: [ - 'fixtures', - '_fixtures', - ], + ignores: [ + 'fixtures', + '_fixtures', + ], }); diff --git a/package.json b/package.json index e0cbd24..4427ba0 100644 --- a/package.json +++ b/package.json @@ -1,82 +1,82 @@ { - "name": "@oncoursesystems/eslint-config", - "type": "module", - "version": "1.0.0", - "description": "OnCourse Systems' ESLint configurations", - "author": "OnCourse Systems For Education", - "license": "MIT", - "homepage": "https://github.com/oncoursesystems/eslint-config#readme", - "repository": { - "type": "git", - "url": "git+https://github.com/oncoursesystems/eslint-config.git" - }, - "keywords": [ - "eslint-config" - ], - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "name": "@oncoursesystems/eslint-config", + "type": "module", + "version": "1.0.0", + "description": "OnCourse Systems' ESLint configurations", + "author": "OnCourse Systems For Education", + "license": "MIT", + "homepage": "https://github.com/oncoursesystems/eslint-config#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/oncoursesystems/eslint-config.git" + }, + "keywords": [ + "eslint-config" + ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.cjs" + } + }, + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "files": [ + "bin", + "dist" + ], + "scripts": { + "build": "tsup --format esm,cjs --clean --dts", + "stub": "tsup --format esm", + "dev": "npx @pn --config eslint.config.ts", + "build:inspector": "pnpm build && npx @eslint/config-inspector build", + "watch": "tsup --format esm,cjs --watch", + "lint": "eslint --flag unstable_ts_config .", + "lint:fix": "eslint --flag unstable_ts_config . --fix", + "prepack": "pnpm build", + "release": "bumpp && pnpm publish", + "test": "vitest", + "typecheck": "tsc --noEmit", + "prepare": "simple-git-hooks" + }, + "dependencies": { + "@antfu/eslint-config": "^3.10.0" + }, + "devDependencies": { + "@eslint-react/eslint-plugin": "^1.17.1", + "@eslint/config-inspector": "^0.5.6", + "@sencha/eslint-plugin-extjs": "^7.8.0", + "@stylistic/eslint-plugin-migrate": "^2.11.0", + "@tanstack/eslint-plugin-query": "^5.61.4", + "@types/fs-extra": "^11.0.4", + "@types/node": "^22.10.0", + "bumpp": "^9.8.1", + "eslint": "^9.15.0", + "eslint-flat-config-utils": "^0.4.0", + "eslint-plugin-expo": "^0.1.0", + "eslint-plugin-format": "^0.1.2", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.14", + "eslint-plugin-tailwindcss": "^3.17.5", + "eslint-typegen": "^0.3.2", + "esno": "^4.8.0", + "execa": "^9.5.1", + "fast-glob": "^3.3.2", + "fs-extra": "^11.2.0", + "jiti": "^2.4.0", + "lint-staged": "^15.2.10", + "prettier": "^3.4.1", + "simple-git-hooks": "^2.11.1", + "tsup": "^8.3.5", + "typescript": "^5.7.2", + "vitest": "^2.1.6", + "wrangler": "^3.90.0" + }, + "simple-git-hooks": { + "pre-commit": "npx lint-staged" + }, + "lint-staged": { + "*": "eslint --flag unstable_ts_config --fix" } - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "bin", - "dist" - ], - "scripts": { - "build": "tsup --format esm,cjs --clean --dts", - "stub": "tsup --format esm", - "dev": "npx @pn --config eslint.config.ts", - "build:inspector": "pnpm build && npx @eslint/config-inspector build", - "watch": "tsup --format esm,cjs --watch", - "lint": "eslint --flag unstable_ts_config .", - "lint:fix": "eslint --flag unstable_ts_config . --fix", - "prepack": "pnpm build", - "release": "bumpp && pnpm publish", - "test": "vitest", - "typecheck": "tsc --noEmit", - "prepare": "simple-git-hooks" - }, - "dependencies": { - "@antfu/eslint-config": "^3.10.0" - }, - "devDependencies": { - "@eslint-react/eslint-plugin": "^1.17.1", - "@eslint/config-inspector": "^0.5.6", - "@sencha/eslint-plugin-extjs": "^7.8.0", - "@stylistic/eslint-plugin-migrate": "^2.11.0", - "@tanstack/eslint-plugin-query": "^5.61.4", - "@types/fs-extra": "^11.0.4", - "@types/node": "^22.10.0", - "bumpp": "^9.8.1", - "eslint": "^9.15.0", - "eslint-flat-config-utils": "^0.4.0", - "eslint-plugin-expo": "^0.1.0", - "eslint-plugin-format": "^0.1.2", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.14", - "eslint-plugin-tailwindcss": "^3.17.5", - "eslint-typegen": "^0.3.2", - "esno": "^4.8.0", - "execa": "^9.5.1", - "fast-glob": "^3.3.2", - "fs-extra": "^11.2.0", - "jiti": "^2.4.0", - "lint-staged": "^15.2.10", - "prettier": "^3.4.1", - "simple-git-hooks": "^2.11.1", - "tsup": "^8.3.5", - "typescript": "^5.7.2", - "vitest": "^2.1.6", - "wrangler": "^3.90.0" - }, - "simple-git-hooks": { - "pre-commit": "npx lint-staged" - }, - "lint-staged": { - "*": "eslint --flag unstable_ts_config --fix" - } } diff --git a/src/config.ts b/src/config.ts index 593b408..58ac9a8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,27 +1,49 @@ -import { expo } from './configs/expo'; -import { javascript } from './configs/javascript'; -import { sencha } from './configs/sencha'; +import process from 'node:process'; -import type { Configs, Options } from './index'; +import type { Configs } from './index'; -export default function oncourseConfigs(options?: Options): Configs { - return [ - options?.expo ? expo() : {}, - javascript(), - options?.sencha ? sencha() : {}, - { - files: ['**/.vscode/*.json'], - rules: { - 'jsonc/sort-array-values': [ - 'error', - { order: { natural: true, type: 'asc' }, pathPattern: '^.*$' }, - ], - 'jsonc/sort-keys': [ - 'error', - 'asc', - { caseSensitive: true, natural: true }, - ], - }, - }, - ]; +const SORT_GROUPS = [ + 'type', + ['builtin', 'external'], + 'internal-type', + 'internal', + ['parent-type', 'sibling-type', 'index-type'], + ['parent', 'sibling', 'index'], + 'object', + 'unknown', +]; + +export default function oncourseConfigs(): Configs { + return [ + { + rules: { + 'perfectionist/sort-imports': [ + 'error', + { + groups: SORT_GROUPS, + internalPattern: ['^#/.+'], + type: 'natural', + }, + ], + 'antfu/if-newline': 'off', + 'antfu/top-level-function': 'off', + 'curly': ['error', 'multi-line'], + 'no-console': [ + process.env.NODE_ENV === 'production' ? 'error' : 'warn', + { + allow: ['table', 'info', 'warn', 'error'], + }, + ], + 'node/prefer-global/process': 'warn', + 'style/comma-dangle': 'off', + 'style/brace-style': ['error', '1tbs', { allowSingleLine: true }], + 'style/jsx-one-expression-per-line': 'off', + 'style/operator-linebreak': [ + 'error', + 'after', + { overrides: { '?': 'before', ':': 'before' } }, + ], + }, + }, + ]; } diff --git a/src/configs/expo.ts b/src/configs/expo.ts deleted file mode 100644 index 12885a2..0000000 --- a/src/configs/expo.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ensurePackages, interopDefault, type TypedFlatConfigItem } from '@antfu/eslint-config'; - -export async function expo(): Promise> { - await ensurePackages(['eslint-plugin-expo']); - const pluginExpo = await interopDefault(import('eslint-plugin-expo')); - - return [ - { - name: 'oncourse/expo/setup', - plugins: { - expo: pluginExpo, - }, - }, - { - name: 'oncourse/expo/rules', - rules: { - 'expo/no-dynamic-env-var': ['error'], - 'expo/no-env-var-destructuring': ['error'], - }, - }, - ]; -} diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts deleted file mode 100644 index 33aa81c..0000000 --- a/src/configs/javascript.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { TypedFlatConfigItem } from '@antfu/eslint-config'; - -const sortOptions = Object.freeze({ - ignoreCase: false, - partitionByNewLine: true, - type: 'natural', -}); - -export function javascript(): TypedFlatConfigItem { - return { - files: ['**/*.{cjs,js,mjs,ts}'], - rules: { - 'perfectionist/sort-array-includes': ['error', sortOptions], - 'perfectionist/sort-enums': ['error', sortOptions], - 'perfectionist/sort-imports': [ - 'error', - { - groups: [['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'], - ignoreCase: false, - type: 'natural', - }, - ], - 'perfectionist/sort-interfaces': ['error', sortOptions], - 'perfectionist/sort-intersection-types': ['error', sortOptions], - 'perfectionist/sort-object-types': ['error', sortOptions], - 'perfectionist/sort-objects': ['error', sortOptions], - 'perfectionist/sort-sets': ['error', sortOptions], - 'perfectionist/sort-union-types': ['error', sortOptions], - 'perfectionist/sort-variable-declarations': ['error', sortOptions], - }, - }; -} diff --git a/src/configs/react.ts b/src/configs/react.ts deleted file mode 100644 index 08a1940..0000000 --- a/src/configs/react.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { OptionsConfig, OptionsOverrides } from '@antfu/eslint-config'; -import pluginQuery from '@tanstack/eslint-plugin-query'; -import type { Linter } from 'eslint'; - -export function reactOverrides(): OptionsOverrides { - return { - overrides: { - }, - }; -} - -export function reactPlugins(options?: OptionsConfig): Array { - return options?.react - ? [ - ...pluginQuery.configs['flat/recommended'], - ] - : []; -} diff --git a/src/configs/sencha.ts b/src/configs/sencha.ts deleted file mode 100644 index 1250cf0..0000000 --- a/src/configs/sencha.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ensurePackages, interopDefault, type TypedFlatConfigItem } from '@antfu/eslint-config'; - -export async function sencha(): Promise> { - await ensurePackages(['@sencha/eslint-plugin-extjs']); - const pluginSencha = await interopDefault(import('@sencha/eslint-plugin-extjs')); - - return [ - { - name: 'oncourse/sencha/setup', - plugins: { - '@sencha/extjs': pluginSencha, - }, - }, - { - name: 'oncourse/sencha/rules', - rules: { - ...pluginSencha.configs.recommended.rules, - }, - }, - ]; -} diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts deleted file mode 100644 index f7049a8..0000000 --- a/src/configs/typescript.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { OptionsOverrides, OptionsTypescript, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from '@antfu/eslint-config'; - -export function typescript(options: OptionsOverrides & OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes = {}): OptionsTypescript { - const { overrides = {} } = options; - - return { - ...options, - overrides: { - 'ts/array-type': [ - 'error', - { - default: 'generic', - }, - ], - 'ts/explicit-member-accessibility': [ - 'error', - { - accessibility: 'explicit', - }, - ], - 'ts/no-redeclare': 'off', - 'ts/no-use-before-define': 'off', - ...overrides, - }, - }; -} diff --git a/src/index.ts b/src/index.ts index 1418f44..b8df3aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,27 +1,41 @@ -import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config'; -import { antfu } from '@antfu/eslint-config'; +import type { + Awaitable, + ConfigNames, + OptionsConfig, + TypedFlatConfigItem, +} from '@antfu/eslint-config'; import type { Linter } from 'eslint'; import type { FlatConfigComposer } from 'eslint-flat-config-utils'; +import { antfu } from '@antfu/eslint-config'; + import oncourseConfigs from './config'; import oncourseOptions from './options'; -export type Options = Omit & OptionsConfig & { - expo?: boolean; - sencha?: boolean; -}; +export type Options = Omit & + OptionsConfig & { + expo?: boolean; + sencha?: boolean; + }; export type Composer = FlatConfigComposer; -export type Configs = Array | Array | FlatConfigComposer | TypedFlatConfigItem>>; +export type Configs = Array< + Awaitable< + | Array + | Array + | FlatConfigComposer + | TypedFlatConfigItem + > +>; -function oncourse(options?: Options, ...configs: Configs): Composer { - return antfu( - { - ...oncourseOptions(options), - ...options, - }, - ...oncourseConfigs(options), - ...configs, - ); +async function oncourse(options?: Options, ...configs: Configs): Promise { + return antfu( + { + ...oncourseOptions(options), + ...options, + }, + ...oncourseConfigs(), + ...configs, + ); } export default oncourse; diff --git a/src/options.ts b/src/options.ts index 5fbd15d..07402f7 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,26 +1,22 @@ import type { OptionsConfig, TypedFlatConfigItem } from '@antfu/eslint-config'; -import { reactOverrides, reactPlugins } from './configs/react'; -import { typescript } from './configs/typescript'; - import type { Options } from './index'; -export default function oncourseOptions(options?: Options): Omit & OptionsConfig { - return { - formatters: { - css: true, - html: true, - markdown: true, - }, - lessOpinionated: true, - name: 'oncourse', - react: options?.react ? reactOverrides() : false, - ...reactPlugins(options), - stylistic: { - indent: 2, - quotes: 'single', - semi: true, - }, - typescript: typescript(), - }; -}; +export default function oncourseOptions( + options?: Options, +): Omit & OptionsConfig { + return { + formatters: true, + name: 'oncourse', + stylistic: { + indent: 4, + quotes: 'single', + semi: true, + }, + typescript: { + tsconfigPath: 'tsconfig.json', + }, + yaml: false, + ...options, + }; +} diff --git a/src/types.d.ts b/src/types.d.ts index 541d7c5..6f29b2e 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,16 +1,16 @@ declare module 'eslint-plugin-expo'; declare module '@sencha/eslint-plugin-extjs' { - import type { ESLint } from 'eslint'; + import type { ESLint } from 'eslint'; - const eslintPluginSencha: ESLint.Plugin & { - configs: { - deprecated: ESLint.Config; - private: ESLint.Config; - recommended: ESLint.Config; - removed: ESLint.Config; + const eslintPluginSencha: ESLint.Plugin & { + configs: { + deprecated: ESLint.Config; + private: ESLint.Config; + recommended: ESLint.Config; + removed: ESLint.Config; + }; }; - }; - export default eslintPluginSencha; + export default eslintPluginSencha; } diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index df8acd2..adb15c8 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -7,97 +7,97 @@ import { afterAll, beforeAll, it } from 'vitest'; import type { OptionsConfig, TypedFlatConfigItem } from '../src/index'; beforeAll(async () => { - await fs.rm('_fixtures', { force: true, recursive: true }); + await fs.rm('_fixtures', { force: true, recursive: true }); }); afterAll(async () => { - await fs.rm('_fixtures', { force: true, recursive: true }); + await fs.rm('_fixtures', { force: true, recursive: true }); }); runWithConfig('js', { - typescript: false, + typescript: false, }); runWithConfig('all', { - typescript: true, + typescript: true, }); runWithConfig('no-style', { - stylistic: false, - typescript: true, + stylistic: false, + typescript: true, }); runWithConfig( - 'tab-double-quotes', - { - stylistic: { - indent: 'tab', - quotes: 'double', + 'tab-double-quotes', + { + stylistic: { + indent: 'tab', + quotes: 'double', + }, + typescript: true, }, - typescript: true, - }, - { - rules: { - 'style/no-mixed-spaces-and-tabs': 'off', + { + rules: { + 'style/no-mixed-spaces-and-tabs': 'off', + }, }, - }, ); // https://github.com/antfu/eslint-config/issues/255 runWithConfig( - 'ts-override', - { - typescript: true, - }, - { - rules: { - 'ts/consistent-type-definitions': ['error', 'type'], + 'ts-override', + { + typescript: true, + }, + { + rules: { + 'ts/consistent-type-definitions': ['error', 'type'], + }, }, - }, ); // https://github.com/antfu/eslint-config/issues/255 runWithConfig( - 'ts-strict', - { - typescript: { - tsconfigPath: './tsconfig.json', + 'ts-strict', + { + typescript: { + tsconfigPath: './tsconfig.json', + }, }, - }, - { - rules: { - 'ts/no-unsafe-return': ['off'], + { + rules: { + 'ts/no-unsafe-return': ['off'], + }, }, - }, ); runWithConfig( - 'with-formatters', - { - formatters: true, - typescript: true, - }, + 'with-formatters', + { + formatters: true, + typescript: true, + }, ); runWithConfig( - 'no-markdown-with-formatters', - { - formatters: { - markdown: true, + 'no-markdown-with-formatters', + { + formatters: { + markdown: true, + }, + jsx: false, + markdown: false, }, - jsx: false, - markdown: false, - }, ); function runWithConfig(name: string, configs: OptionsConfig, ...items: Array) { - it.concurrent(name, async ({ expect }) => { - const from = resolve('fixtures/input'); - const output = resolve('fixtures/output', name); - const target = resolve('_fixtures', name); + it.concurrent(name, async ({ expect }) => { + const from = resolve('fixtures/input'); + const output = resolve('fixtures/output', name); + const target = resolve('_fixtures', name); - await fs.copy(from, target, { - filter: (src) => { - return !src.includes('node_modules'); - }, - }); - await fs.writeFile(join(target, 'eslint.config.js'), ` + await fs.copy(from, target, { + filter: (src) => { + return !src.includes('node_modules'); + }, + }); + await fs.writeFile(join(target, 'eslint.config.js'), ` // @eslint-disable import antfu from '@antfu/eslint-config' @@ -107,30 +107,30 @@ export default antfu( ) `); - await execa('npx', ['eslint', '.', '--fix'], { - cwd: target, - stdio: 'pipe', - }); + await execa('npx', ['eslint', '.', '--fix'], { + cwd: target, + stdio: 'pipe', + }); - const files = await fg('**/*', { - cwd: target, - ignore: [ - 'node_modules', - 'eslint.config.js', - ], - }); + const files = await fg('**/*', { + cwd: target, + ignore: [ + 'node_modules', + 'eslint.config.js', + ], + }); - await Promise.all(files.map(async (file) => { - const content = await fs.readFile(join(target, file), 'utf-8'); - const source = await fs.readFile(join(from, file), 'utf-8'); - const outputPath = join(output, file); - if (content === source) { - if (fs.existsSync(outputPath)) { - await fs.remove(outputPath); - } - return; - } - await expect.soft(content).toMatchFileSnapshot(join(output, file)); - })); - }, 30_000); + await Promise.all(files.map(async (file) => { + const content = await fs.readFile(join(target, file), 'utf-8'); + const source = await fs.readFile(join(from, file), 'utf-8'); + const outputPath = join(output, file); + if (content === source) { + if (fs.existsSync(outputPath)) { + await fs.remove(outputPath); + } + return; + } + await expect.soft(content).toMatchFileSnapshot(join(output, file)); + })); + }, 30_000); } diff --git a/tsconfig.json b/tsconfig.json index 24acd01..bf7df03 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,16 @@ { - "compilerOptions": { - "target": "ESNext", - "baseUrl": ".", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true - }, - "include": ["**/*.ts"], - "exclude": [ - "./fixtures/**/*.*", - "./_fixtures/**/*.*" - ] + "compilerOptions": { + "target": "ESNext", + "baseUrl": ".", + "module": "ESNext", + "moduleResolution": "Bundler", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true + }, + "include": ["**/*.ts"], + "exclude": [ + "./fixtures/**/*.*", + "./_fixtures/**/*.*" + ] } diff --git a/tsup.config.ts b/tsup.config.ts index 0046d12..45a342c 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from 'tsup'; export default defineConfig({ - entry: ['src/index.ts'], - shims: true, + entry: ['src/index.ts'], + shims: true, });