diff --git a/.github/workflows/ores-lint.yml b/.github/workflows/ores-lint.yml new file mode 100644 index 0000000..722a91c --- /dev/null +++ b/.github/workflows/ores-lint.yml @@ -0,0 +1,54 @@ +# Managed by .ores-lint/ - regenerated by the rollout script. +name: ores-lint + +on: + pull_request: + workflow_dispatch: + # Add `push:` here once this repo's lint debt is paid down. + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Detect project types + id: detect + run: | + { [ -f package.json ] || git ls-files '*.js' '*.mjs' '*.cjs' '*.ts' '*.tsx' | grep -q .; } \ + && echo "js=true" >> "$GITHUB_OUTPUT" || echo "js=false" >> "$GITHUB_OUTPUT" + { [ -f Cargo.toml ] || git ls-files '*.rs' | grep -q .; } \ + && echo "rs=true" >> "$GITHUB_OUTPUT" || echo "rs=false" >> "$GITHUB_OUTPUT" + { [ -f pubspec.yaml ] || git ls-files '*.dart' | grep -q .; } \ + && echo "dart=true" >> "$GITHUB_OUTPUT" || echo "dart=false" >> "$GITHUB_OUTPUT" + { [ -f gleam.toml ] || git ls-files '*.gleam' | grep -q .; } \ + && echo "gleam=true" >> "$GITHUB_OUTPUT" || echo "gleam=false" >> "$GITHUB_OUTPUT" + + # Node is the runner for ESLint and for the cross-language require-send + # scanner, so it is installed whenever any supported language is present. + - uses: actions/setup-node@v4 + if: steps.detect.outputs.js == 'true' || steps.detect.outputs.rs == 'true' || steps.detect.outputs.dart == 'true' || steps.detect.outputs.gleam == 'true' + with: + node-version: '22' + + # ESLint is a global tool here, not a repo dependency - so this job never + # runs `npm install` and never needs the repo's node_modules. + - name: Install eslint globally + if: steps.detect.outputs.js == 'true' + run: npm i -g eslint typescript-eslint + + - name: Install clippy + if: steps.detect.outputs.rs == 'true' + run: rustup component add clippy || true + + # Dart/Gleam SDKs are optional. When absent, dart.sh / gleam.sh skip + # with an actionable message; require-send.mjs still runs via Node. + - uses: dart-lang/setup-dart@v1 + if: steps.detect.outputs.dart == 'true' + continue-on-error: true + + - name: Run ores-lint + run: sh .ores-lint/lint.sh + env: + # Warn-only. Set to 1 here to make lint findings fail this repo's CI. + ORES_LINT_STRICT: '0' diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..ee5719d --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,11 @@ +// ores-lint house ESLint config. +// Managed by .ores-lint/ - see .ores-lint/README.md before editing. +// Repo-specific tweaks go in the options object below; the rollout script will +// not overwrite this file once you have changed it. +import oresConfig from './.ores-lint/eslint/base.mjs'; + +export default await oresConfig({ + // requireSend: { loggerNames: ['myLogger'], terminalMethods: ['send', 'flush'] }, + // rules: { 'no-console': 'warn' }, + // ignores: ['**/generated/**'], +}); diff --git a/package.json b/package.json index 17816f5..fdbfc8f 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,16 @@ "engines": { "vscode": "^1.95.0" }, - "categories": ["Other", "Linters"], - "keywords": ["zed-pkg", "package manager", "dependencies", "lockfile"], + "categories": [ + "Other", + "Linters" + ], + "keywords": [ + "zed-pkg", + "package manager", + "dependencies", + "lockfile" + ], "repository": { "type": "git", "url": "https://github.com/zed-pkg/zed-vscode.git" @@ -24,7 +32,9 @@ "test": "node --test test/*.test.js", "test:extension": "node test/integration/run.js", "verify": "node scripts/verify-repository.js", - "package": "vsce package" + "package": "vsce package", + "lint:ores": "if [ -f .ores-lint/lint.sh ]; then sh .ores-lint/lint.sh; else echo 'ores-lint not installed'; fi", + "prepublishOnly": "npm run lint:ores" }, "devDependencies": { "@vscode/test-electron": "2.5.2", @@ -32,19 +42,38 @@ }, "contributes": { "commands": [ - {"command": "zedPackageInsights.refresh", "title": "Zed: Refresh Package Insights"}, - {"command": "zedPackageInsights.show", "title": "Zed: Show Package Insights"}, - {"command": "zedPackageInsights.actions", "title": "Zed: Recommended Actions"}, - {"command": "zedPackageInsights.openSettings", "title": "Preferences: Zed Package Insights Settings"} + { + "command": "zedPackageInsights.refresh", + "title": "Zed: Refresh Package Insights" + }, + { + "command": "zedPackageInsights.show", + "title": "Zed: Show Package Insights" + }, + { + "command": "zedPackageInsights.actions", + "title": "Zed: Recommended Actions" + }, + { + "command": "zedPackageInsights.openSettings", + "title": "Preferences: Zed Package Insights Settings" + } ], "viewsContainers": { "activitybar": [ - {"id": "zedPackageInsights", "title": "Zed Packages", "icon": "resources/zed.svg"} + { + "id": "zedPackageInsights", + "title": "Zed Packages", + "icon": "resources/zed.svg" + } ] }, "views": { "zedPackageInsights": [ - {"id": "zedPackageInsights.packages", "name": "Package Insights"} + { + "id": "zedPackageInsights.packages", + "name": "Package Insights" + } ] }, "configuration": { @@ -76,5 +105,13 @@ } } } + }, + "oresLint": { + "note": "Declared, not installed. ores-lint resolves these from a global install - see .ores-lint/README.md", + "requires": { + "eslint": ">=9", + "typescript-eslint": ">=8 (optional; without it .ts files are skipped)" + }, + "install": "npm i -g eslint typescript-eslint" } }