diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e9a6cc459..428d4e786 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,14 +49,11 @@ jobs: node-version: 20 cache: 'yarn' - run: yarn install --immutable --immutable-cache - - run: yarn tsc - - run: yarn oxlint . - - run: yarn prettier --check . - - run: yarn eslint . + - run: yarn turbo tsc lint - name: Validate package setup run: | yarn setup - yarn prettier --write . + yarn nano-staged git diff --exit-code -- . :^.yarn Unit: diff --git a/.prettierignore b/.prettierignore index 3f7d83221..7bfe68b4d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,4 @@ .yarn .tshy coverage +dist diff --git a/eslint.config.js b/eslint.config.js index d89b32a99..ee59a27ef 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,108 +1,3 @@ -// @ts-check -import eslint from '@eslint/js'; -import globals from 'globals'; -import tseslint from 'typescript-eslint'; -import nodePlugin from 'eslint-plugin-n'; -import oxlint from 'eslint-plugin-oxlint'; +import config from '@repo/eslint-config'; -export default tseslint.config( - { - ignores: [ - '.git', - 'node_modules', - 'coverage', - '.yarn', - 'packages/*/dist/**', - 'packages/*/node_modules/**', - 'packages/*/__snapshots__/**', - ], - }, - eslint.configs.recommended, - nodePlugin.configs['flat/recommended-module'], - { - languageOptions: { - globals: { - ...globals.nodeBuiltin, - }, - }, - rules: { - 'n/hashbang': 'off', - 'unicorn/consistent-function-scoping': 'off', - 'unicorn/filename-case': 'off', - 'unicorn/no-array-callback-reference': 'off', - 'unicorn/no-array-for-each': 'off', - 'unicorn/no-array-reduce': 'off', - 'unicorn/no-null': 'off', - 'unicorn/no-process-exit': 'off', - 'unicorn/prefer-event-target': 'off', - 'unicorn/prefer-top-level-await': 'off', - 'unicorn/prevent-abbreviations': 'off', - }, - }, - { - files: ['**/*.mts', '**/*.ts'], - extends: [...tseslint.configs.strictTypeChecked], - languageOptions: { - parserOptions: { - projectService: true, - }, - }, - rules: { - '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/no-invalid-void-type': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-confusing-void-expression': 'off', - '@typescript-eslint/no-unnecessary-type-parameters': 'off', - }, - }, - { - files: ['**/*.cjs'], - extends: [nodePlugin.configs['flat/recommended-script']], - languageOptions: { - globals: { - ...globals.node, - }, - }, - }, - { - files: ['packages/inquirer/test/**', 'packages/**/*.test.*'], - rules: { - '@typescript-eslint/unbound-method': 'off', - 'n/no-extraneous-import': [ - 'error', - { - allowModules: ['vitest'], - }, - ], - 'n/no-extraneous-require': [ - 'error', - { - allowModules: ['vitest'], - }, - ], - 'n/no-unsupported-features/node-builtins': [ - 'error', - { - version: '>=22.0.0', - }, - ], - }, - }, - { - files: [ - 'tools/**', - 'integration/**', - 'packages/inquirer/examples/**', - 'packages/demo/**', - ], - rules: { - 'n/no-unsupported-features/node-builtins': [ - 'error', - { - version: '>=22.0.0', - }, - ], - }, - }, - ...oxlint.configs['flat/recommended'], -); +export default config; diff --git a/internals/eslint-config/index.js b/internals/eslint-config/index.js new file mode 100644 index 000000000..267ddfd09 --- /dev/null +++ b/internals/eslint-config/index.js @@ -0,0 +1,86 @@ +// @ts-check +import eslint from '@eslint/js'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; +import nodePlugin from 'eslint-plugin-n'; +import oxlint from 'eslint-plugin-oxlint'; + +export default tseslint.config( + { + ignores: [ + '.git', + 'node_modules', + 'coverage', + '.yarn', + '**/dist/**', + '**/node_modules/**', + '**/__snapshots__/**', + ], + }, + eslint.configs.recommended, + nodePlugin.configs['flat/recommended-module'], + { + languageOptions: { + globals: { + ...globals.nodeBuiltin, + }, + }, + rules: { + 'n/hashbang': 'off', + 'unicorn/consistent-function-scoping': 'off', + 'unicorn/filename-case': 'off', + 'unicorn/no-array-callback-reference': 'off', + 'unicorn/no-array-for-each': 'off', + 'unicorn/no-array-reduce': 'off', + 'unicorn/no-null': 'off', + 'unicorn/no-process-exit': 'off', + 'unicorn/prefer-event-target': 'off', + 'unicorn/prefer-top-level-await': 'off', + 'unicorn/prevent-abbreviations': 'off', + }, + }, + { + files: ['**/*.mts', '**/*.ts'], + extends: [...tseslint.configs.strictTypeChecked], + languageOptions: { + parserOptions: { + projectService: true, + }, + }, + rules: { + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/no-invalid-void-type': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-confusing-void-expression': 'off', + '@typescript-eslint/no-unnecessary-type-parameters': 'off', + }, + }, + { + files: ['**/*.cjs'], + extends: [nodePlugin.configs['flat/recommended-script']], + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, + { + files: ['**/test/**', '**/*.test.*', 'tools/**', 'packages/inquirer/examples/**'], + rules: { + '@typescript-eslint/unbound-method': 'off', + 'n/no-extraneous-import': [ + 'error', + { + allowModules: ['vitest'], + }, + ], + 'n/no-unsupported-features/node-builtins': [ + 'error', + { + version: '>=22.0.0', + }, + ], + }, + }, + ...oxlint.configs['flat/recommended'], +); diff --git a/internals/eslint-config/package.json b/internals/eslint-config/package.json new file mode 100644 index 000000000..deb6319a5 --- /dev/null +++ b/internals/eslint-config/package.json @@ -0,0 +1,15 @@ +{ + "name": "@repo/eslint-config", + "version": "0.0.0", + "private": true, + "type": "module", + "main": "index.js", + "dependencies": { + "@eslint/js": "^9.31.0", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-n": "^17.21.0", + "eslint-plugin-oxlint": "^1.7.0", + "globals": "^16.3.0", + "typescript-eslint": "^8.37.0" + } +} diff --git a/package.json b/package.json index 4eebb7782..b1bed668f 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "prepack": "find packages/* -maxdepth 1 -type f -name 'README*' -exec sed -i '' -e 's/utm_source=github/utm_source=npmjs/g' {} + && find packages/* -maxdepth 1 -type f -name package.json -exec sh -c 'jq \".devDependencies |= with_entries(select(.value != \\\"workspace:*\\\"))\" \"$1\" > \"$1.tmp\" && mv \"$1.tmp\" \"$1\"' _ {} \\;", "postpack": "git restore packages/*/package.json packages/*/README.md", "setup": "node ./tools/setup-packages.mjs", - "pretest": "turbo tsc && oxlint && prettier --check . && eslint . && yarn tsc:test", + "pretest": "turbo tsc lint && yarn tsc:test", "test": "vitest --run packages && node --test integration/**/*.test.*", "tsc": "turbo tsc", "tsc:test": "tsc -p tsconfig.json" @@ -75,17 +75,13 @@ "type-fest": "^4.0.0" }, "devDependencies": { - "@eslint/js": "^9.31.0", + "@repo/eslint-config": "workspace:*", "@repo/hoist-peer-dependencies": "workspace:*", "@repo/tsconfig": "workspace:*", "@types/node": "^24.0.15", "@vitest/coverage-v8": "^3.2.4", "@vitest/ui": "^3.2.4", "eslint": "^9.31.0", - "eslint-config-prettier": "^10.1.8", - "eslint-plugin-n": "^17.21.0", - "eslint-plugin-oxlint": "^1.7.0", - "globals": "^16.3.0", "globby": "^14.1.0", "husky": "^9.1.7", "lerna": "^8.2.3", @@ -94,7 +90,6 @@ "prettier": "^3.6.2", "turbo": "^2.5.5", "typescript": "^5.8.3", - "typescript-eslint": "^8.37.0", "vitest": "^3.2.4" }, "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9", diff --git a/packages/checkbox/eslint.config.js b/packages/checkbox/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/checkbox/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/checkbox/package.json b/packages/checkbox/package.json index 232463130..53f532235 100644 --- a/packages/checkbox/package.json +++ b/packages/checkbox/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -83,6 +84,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/confirm/eslint.config.js b/packages/confirm/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/confirm/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/confirm/package.json b/packages/confirm/package.json index dbd9f5891..078d1cc2a 100644 --- a/packages/confirm/package.json +++ b/packages/confirm/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -80,6 +81,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/core/eslint.config.js b/packages/core/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/core/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/core/package.json b/packages/core/package.json index c449e4164..225d0d5c1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/figures": "^1.0.12", @@ -86,6 +87,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "@types/mute-stream": "^0.0.4", "@types/node": "^24.0.15", diff --git a/packages/demo/eslint.config.js b/packages/demo/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/demo/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/demo/package.json b/packages/demo/package.json index 58fac6384..4f59239f7 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -67,7 +67,8 @@ "dist" ], "scripts": { - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -76,12 +77,13 @@ "yoctocolors-cjs": "^2.1.2" }, "devDependencies": { + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "@types/node": "^24.0.15", "tshy": "^3.0.2" }, "engines": { - "node": ">=18" + "node": ">=22" }, "publishConfig": { "access": "public" diff --git a/packages/editor/eslint.config.js b/packages/editor/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/editor/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/editor/package.json b/packages/editor/package.json index bc31f16d4..cfeed5260 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -81,6 +82,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/expand/eslint.config.js b/packages/expand/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/expand/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/expand/package.json b/packages/expand/package.json index 04025f91e..0e7cc8ce4 100644 --- a/packages/expand/package.json +++ b/packages/expand/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -81,6 +82,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/figures/eslint.config.js b/packages/figures/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/figures/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/figures/package.json b/packages/figures/package.json index c5aea0c8e..d81b0626c 100644 --- a/packages/figures/package.json +++ b/packages/figures/package.json @@ -72,10 +72,12 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/input/eslint.config.js b/packages/input/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/input/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/input/package.json b/packages/input/package.json index 8d59fe684..30ebf2728 100644 --- a/packages/input/package.json +++ b/packages/input/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -80,6 +81,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/inquirer/eslint.config.js b/packages/inquirer/eslint.config.js new file mode 100644 index 000000000..cd379440f --- /dev/null +++ b/packages/inquirer/eslint.config.js @@ -0,0 +1,16 @@ +import config from '@repo/eslint-config'; + +export default [ + ...config, + { + files: ['examples/**'], + rules: { + 'n/no-unsupported-features/node-builtins': [ + 'error', + { + version: '>=22.0.0', + }, + ], + }, + }, +]; diff --git a/packages/inquirer/package.json b/packages/inquirer/package.json index ef654b3a4..20b779d51 100644 --- a/packages/inquirer/package.json +++ b/packages/inquirer/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -84,6 +85,7 @@ }, "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "@types/mute-stream": "^0.0.4", "tshy": "^3.0.2" diff --git a/packages/number/eslint.config.js b/packages/number/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/number/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/number/package.json b/packages/number/package.json index 62fe481ca..eb89efd2a 100644 --- a/packages/number/package.json +++ b/packages/number/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -80,6 +81,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/password/eslint.config.js b/packages/password/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/password/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/password/package.json b/packages/password/package.json index 8ee78aaa8..55dd529d5 100644 --- a/packages/password/package.json +++ b/packages/password/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -81,6 +82,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/prompts/eslint.config.js b/packages/prompts/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/prompts/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/prompts/package.json b/packages/prompts/package.json index 5d567df2e..42c1415cb 100644 --- a/packages/prompts/package.json +++ b/packages/prompts/package.json @@ -73,7 +73,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/checkbox": "^4.1.9", @@ -90,6 +91,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/type": "^3.0.7", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/rawlist/eslint.config.js b/packages/rawlist/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/rawlist/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/rawlist/package.json b/packages/rawlist/package.json index b75f69064..7def2cab1 100644 --- a/packages/rawlist/package.json +++ b/packages/rawlist/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -81,6 +82,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/search/eslint.config.js b/packages/search/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/search/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/search/package.json b/packages/search/package.json index 6ae5f0d23..1faab038e 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -82,6 +83,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/select/eslint.config.js b/packages/select/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/select/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/select/package.json b/packages/select/package.json index 75c4e01bb..b336ce199 100644 --- a/packages/select/package.json +++ b/packages/select/package.json @@ -71,7 +71,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/core": "^10.1.14", @@ -83,6 +84,7 @@ "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@inquirer/testing": "^2.1.48", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/packages/testing/eslint.config.js b/packages/testing/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/testing/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/testing/package.json b/packages/testing/package.json index ef2333290..1e962533c 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -74,7 +74,8 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "dependencies": { "@inquirer/type": "^3.0.7", @@ -83,6 +84,7 @@ }, "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "@types/mute-stream": "^0.0.4", "@types/node": "^24.0.15", diff --git a/packages/type/eslint.config.js b/packages/type/eslint.config.js new file mode 100644 index 000000000..ee59a27ef --- /dev/null +++ b/packages/type/eslint.config.js @@ -0,0 +1,3 @@ +import config from '@repo/eslint-config'; + +export default config; diff --git a/packages/type/package.json b/packages/type/package.json index 660a87375..7fcd45661 100644 --- a/packages/type/package.json +++ b/packages/type/package.json @@ -72,10 +72,12 @@ ], "scripts": { "attw": "attw --pack", - "tsc": "tshy" + "tsc": "tshy", + "lint": "oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore" }, "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", + "@repo/eslint-config": "workspace:*", "@repo/tsconfig": "workspace:*", "tshy": "^3.0.2" }, diff --git a/tools/setup-packages.mjs b/tools/setup-packages.mjs index ee2e43148..001a2b12d 100644 --- a/tools/setup-packages.mjs +++ b/tools/setup-packages.mjs @@ -28,6 +28,10 @@ const versions = {}; const rootPkg = await readJSONFile(path.join(import.meta.dirname, '../package.json')); const paths = await globby(['packages/**/package.json', '!**/node_modules']); +const eslintConfig = await readFile( + path.join(import.meta.dirname, '../eslint.config.js'), +); + Promise.all( paths.map(async (pkgPath) => { const pkg = await readJSONFile(pkgPath); @@ -46,28 +50,41 @@ Promise.all( const hasReadme = await fileExists(path.join(dir, 'README.md')); // Replicate configs that should always be the same. - pkg.engines = rootPkg.engines; pkg.author = rootPkg.author; pkg.license = rootPkg.license; pkg.repository = rootPkg.repository; pkg.keywords = [...new Set([...rootPkg.keywords, ...(pkg.keywords ?? [])])]; pkg.sideEffects = pkg.sideEffects ?? false; + if (pkg.name !== '@inquirer/demo') { + pkg.engines = rootPkg.engines; + } + if (hasReadme) { const repoPath = dir.split('/').slice(-2).join('/'); pkg.homepage = `https://github.com/SBoudrias/Inquirer.js/blob/main/${repoPath}/README.md`; } + pkg.devDependencies = pkg.devDependencies ?? {}; + pkg.scripts = pkg.scripts ?? {}; + + // Setup linting + pkg.devDependencies['oxlint'] = versions['oxlint']; + pkg.devDependencies['eslint'] = versions['eslint']; + pkg.devDependencies['prettier'] = versions['prettier']; + pkg.devDependencies['@repo/eslint-config'] = 'workspace:*'; + pkg.scripts.lint = + 'oxlint --config=../../.oxlintrc.json && eslint . && prettier . --check --config=../../.prettierrc.mjs --ignore-path=../../.prettierignore'; + writeFile(path.join(dir, 'eslint.config.js'), eslintConfig); + if (isTS) { pkg.files = ['dist']; - pkg.devDependencies = pkg.devDependencies ?? {}; pkg.devDependencies['tshy'] = versions['tshy']; pkg.tshy = pkg.tshy ?? {}; pkg.tshy.exclude = ['src/**/*.test.ts']; - pkg.scripts = pkg.scripts ?? {}; pkg.scripts.tsc = 'tshy'; // Only set attw if the package is using commonjs diff --git a/turbo.json b/turbo.json index 296e653e6..30fd4e801 100644 --- a/turbo.json +++ b/turbo.json @@ -8,7 +8,15 @@ "tsc": { "dependsOn": ["^tsc"], "outputs": ["dist/**"], - "inputs": ["$TURBO_DEFAULT$", "../../package.json"] + "inputs": ["tsconfig.json", ".tshy/**", "src/**"] + }, + "lint": { + "inputs": [ + "$TURBO_DEFAULT$", + "$TURBO_ROOT$/.oxlintrc.json", + "$TURBO_ROOT$/.prettierrc.mjs", + "$TURBO_ROOT$/.prettierignore" + ] } } } diff --git a/yarn.lock b/yarn.lock index 607b64a9a..995ccb696 100644 --- a/yarn.lock +++ b/yarn.lock @@ -481,6 +481,7 @@ __metadata: "@inquirer/figures": "npm:^1.0.12" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" ansi-escapes: "npm:^4.3.2" tshy: "npm:^3.0.2" @@ -512,6 +513,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" peerDependencies: @@ -530,6 +532,7 @@ __metadata: "@inquirer/figures": "npm:^1.0.12" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" "@types/mute-stream": "npm:^0.0.4" "@types/node": "npm:^24.0.15" @@ -556,6 +559,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/figures": "npm:^1.0.12" "@inquirer/prompts": "npm:^7.6.0" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" "@types/node": "npm:^24.0.15" tshy: "npm:^3.0.2" @@ -578,6 +582,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" external-editor: "npm:^3.1.0" tshy: "npm:^3.0.2" @@ -608,6 +613,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" yoctocolors-cjs: "npm:^2.1.2" @@ -624,6 +630,7 @@ __metadata: resolution: "@inquirer/figures@workspace:packages/figures" dependencies: "@arethetypeswrong/cli": "npm:^0.18.2" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" languageName: unknown @@ -637,6 +644,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" peerDependencies: @@ -655,6 +663,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" peerDependencies: @@ -673,6 +682,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" ansi-escapes: "npm:^4.3.2" tshy: "npm:^3.0.2" @@ -700,6 +710,7 @@ __metadata: "@inquirer/search": "npm:^3.0.16" "@inquirer/select": "npm:^4.2.4" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" peerDependencies: @@ -718,6 +729,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" yoctocolors-cjs: "npm:^2.1.2" @@ -733,17 +745,13 @@ __metadata: version: 0.0.0-use.local resolution: "@inquirer/root@workspace:." dependencies: - "@eslint/js": "npm:^9.31.0" + "@repo/eslint-config": "workspace:*" "@repo/hoist-peer-dependencies": "workspace:*" "@repo/tsconfig": "workspace:*" "@types/node": "npm:^24.0.15" "@vitest/coverage-v8": "npm:^3.2.4" "@vitest/ui": "npm:^3.2.4" eslint: "npm:^9.31.0" - eslint-config-prettier: "npm:^10.1.8" - eslint-plugin-n: "npm:^17.21.0" - eslint-plugin-oxlint: "npm:^1.7.0" - globals: "npm:^16.3.0" globby: "npm:^14.1.0" husky: "npm:^9.1.7" lerna: "npm:^8.2.3" @@ -752,7 +760,6 @@ __metadata: prettier: "npm:^3.6.2" turbo: "npm:^2.5.5" typescript: "npm:^5.8.3" - typescript-eslint: "npm:^8.37.0" vitest: "npm:^3.2.4" languageName: unknown linkType: soft @@ -766,6 +773,7 @@ __metadata: "@inquirer/figures": "npm:^1.0.12" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" yoctocolors-cjs: "npm:^2.1.2" @@ -786,6 +794,7 @@ __metadata: "@inquirer/figures": "npm:^1.0.12" "@inquirer/testing": "npm:^2.1.48" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" ansi-escapes: "npm:^4.3.2" tshy: "npm:^3.0.2" @@ -804,6 +813,7 @@ __metadata: dependencies: "@arethetypeswrong/cli": "npm:^0.18.2" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" "@types/mute-stream": "npm:^0.0.4" "@types/node": "npm:^24.0.15" @@ -823,6 +833,7 @@ __metadata: resolution: "@inquirer/type@workspace:packages/type" dependencies: "@arethetypeswrong/cli": "npm:^0.18.2" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" tshy: "npm:^3.0.2" peerDependencies: @@ -1571,6 +1582,19 @@ __metadata: languageName: node linkType: hard +"@repo/eslint-config@workspace:*, @repo/eslint-config@workspace:internals/eslint-config": + version: 0.0.0-use.local + resolution: "@repo/eslint-config@workspace:internals/eslint-config" + dependencies: + "@eslint/js": "npm:^9.31.0" + eslint-config-prettier: "npm:^10.1.8" + eslint-plugin-n: "npm:^17.21.0" + eslint-plugin-oxlint: "npm:^1.7.0" + globals: "npm:^16.3.0" + typescript-eslint: "npm:^8.37.0" + languageName: unknown + linkType: soft + "@repo/hoist-peer-dependencies@workspace:*, @repo/hoist-peer-dependencies@workspace:internals/hoist-peer-dependencies": version: 0.0.0-use.local resolution: "@repo/hoist-peer-dependencies@workspace:internals/hoist-peer-dependencies" @@ -4619,6 +4643,7 @@ __metadata: "@inquirer/core": "npm:^10.1.14" "@inquirer/prompts": "npm:^7.6.0" "@inquirer/type": "npm:^3.0.7" + "@repo/eslint-config": "workspace:*" "@repo/tsconfig": "workspace:*" "@types/mute-stream": "npm:^0.0.4" ansi-escapes: "npm:^4.3.2"