From 021e51352071e51909d2de5bdfa33d7b04f7e4ed Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 10 Nov 2026 17:30:14 -0500 Subject: [PATCH 1/6] chore: set up project tooling Co-Authored-By: Claude Fable 5.2 --- .gitattributes | 4 + .github/CODEOWNERS | 2 + .github/ISSUE_TEMPLATE/bug-report.yml | 93 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/change.yml | 67 +++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 8 ++ .github/ISSUE_TEMPLATE/docs.yml | 62 ++++++++++++++++ .github/ISSUE_TEMPLATE/new-rule.yml | 66 +++++++++++++++++ .github/ISSUE_TEMPLATE/rule-change.yml | 77 ++++++++++++++++++++ .github/renovate.json5 | 4 + .github/workflows/add-to-triage.yml | 22 ++++++ .github/workflows/ci-bun.yml | 17 +++++ .github/workflows/ci-package-manager.yml | 17 +++++ .github/workflows/ci.yml | 50 +++++++++++++ .github/workflows/publish-release.yml | 41 +++++++++++ .github/workflows/release-please.yml | 33 +++++++++ .github/workflows/stale.yml | 15 ++++ .github/workflows/update-readme.yml | 16 ++++ .gitignore | 64 +++++++++++++++- .npmrc | 2 + .prettierignore | 3 + .release-please-manifest.json | 3 + README.md | 48 ++++++++++++ eslint.config.js | 88 ++++++++++++++++++++++ package.json | 81 +++++++++++++++++++++ prettier.config.js | 15 ++++ release-please-config.json | 11 +++ src/index.spec.ts | 23 ++++++ src/index.ts | 24 ++++++ tsconfig.build.json | 10 +++ tsconfig.json | 18 +++++ vitest.config.ts | 27 +++++++ 31 files changed, 1009 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/change.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/docs.yml create mode 100644 .github/ISSUE_TEMPLATE/new-rule.yml create mode 100644 .github/ISSUE_TEMPLATE/rule-change.yml create mode 100644 .github/renovate.json5 create mode 100644 .github/workflows/add-to-triage.yml create mode 100644 .github/workflows/ci-bun.yml create mode 100644 .github/workflows/ci-package-manager.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/stale.yml create mode 100644 .github/workflows/update-readme.yml create mode 100644 .npmrc create mode 100644 .prettierignore create mode 100644 .release-please-manifest.json create mode 100644 README.md create mode 100644 eslint.config.js create mode 100644 package.json create mode 100644 prettier.config.js create mode 100644 release-please-config.json create mode 100644 src/index.spec.ts create mode 100644 src/index.ts create mode 100644 tsconfig.build.json create mode 100644 tsconfig.json create mode 100644 vitest.config.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..accffc8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Convert text file line endings to lf +* text=auto + +*.js text eol=lf diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..758589a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +.release-please-manifest.json @eslint/eslint-tsc +.github/workflows/release-please.yml @eslint/eslint-tsc diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..5256888 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,93 @@ +name: "\U0001F41E Report a problem" +description: "Report something that isn't working the way you expected." +title: "Bug: (fill in)" +labels: + - bug + - "repro:needed" +body: + - type: markdown + attributes: + value: By opening an issue, you agree to abide by the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). + - type: textarea + id: environment + attributes: + label: Environment + description: | + Please tell us about how you're running ESLint (Run `npx eslint --env-info`.) + value: | + ESLint version: + @eslint/docker version: + Node version: + npm version: + Operating System: + validations: + required: true + - type: textarea + id: description + attributes: + label: What did you do? + description: | + Please include a *minimal* reproduction case with your ESLint configuration and Dockerfile. + value: | +
+ Configuration + + ```js + // Paste your configuration here + ``` +
+ + ```dockerfile + # Paste your code here + ``` + validations: + required: true + - type: textarea + id: expectation + attributes: + label: What did you expect to happen? + validations: + required: true + - type: textarea + id: lint-output + attributes: + label: What actually happened? + description: | + Please copy-paste the actual ESLint output. + validations: + required: true + - type: input + id: repro-url + attributes: + label: Link to Minimal Reproducible Example + description: "Link to a [StackBlitz](https://stackblitz.com) or GitHub repo with a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed." + placeholder: "https://stackblitz.com/abcd1234" + validations: + required: true + - type: checkboxes + attributes: + label: Participation + options: + - label: I am willing to submit a pull request for this issue. + required: false + - type: markdown + attributes: + value: Please **do not** open a pull request until this issue has been accepted by the team. + - type: checkboxes + attributes: + label: AI acknowledgment + description: Check all that apply. + options: + - label: I did not use AI to generate this issue report. + required: false + - label: I used AI to translate the content of this issue report. + required: false + - label: I used AI to understand the codebase. + required: false + - label: I used AI to generate content for this issue report and I reviewed the generated content. + required: false + - type: textarea + id: comments + attributes: + label: Additional comments + description: Is there anything else that's important for the team to know? diff --git a/.github/ISSUE_TEMPLATE/change.yml b/.github/ISSUE_TEMPLATE/change.yml new file mode 100644 index 0000000..9d8222e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/change.yml @@ -0,0 +1,67 @@ +name: "\U0001F680 Request a change (not rule-related)" +description: "Request a change that is not a bug fix, rule change, or new rule" +title: "Change Request: (fill in)" +labels: + - enhancement + - core +body: + - type: markdown + attributes: + value: By opening an issue, you agree to abide by the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). + - type: textarea + attributes: + label: Environment + description: | + Please tell us about how you're running ESLint (Run `npx eslint --env-info`.) + value: | + ESLint version: + @eslint/docker version: + Node version: + npm version: + Operating System: + validations: + required: true + - type: textarea + attributes: + label: What problem do you want to solve? + description: | + Please explain your use case in as much detail as possible. + placeholder: | + The Docker plugin currently... + validations: + required: true + - type: textarea + attributes: + label: What do you think is the correct solution? + description: | + Please explain how you'd like to change the Docker plugin to address the problem. + placeholder: | + I'd like the Docker plugin to... + validations: + required: true + - type: checkboxes + attributes: + label: Participation + options: + - label: I am willing to submit a pull request for this change. + required: false + - type: markdown + attributes: + value: Please **do not** open a pull request until this issue has been accepted by the team. + - type: checkboxes + attributes: + label: AI acknowledgment + description: Check all that apply. + options: + - label: I did not use AI to generate this issue report. + required: false + - label: I used AI to translate the content of this issue report. + required: false + - label: I used AI to understand the codebase. + required: false + - label: I used AI to generate content for this issue report and I reviewed the generated content. + required: false + - type: textarea + attributes: + label: Additional comments + description: Is there anything else that's important for the team to know? diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3acb21c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: 🗣 Ask a Question, Discuss + url: https://github.com/eslint/docker/discussions + about: Get help using this plugin + - name: Discord Server + url: https://eslint.org/chat + about: Talk with the team diff --git a/.github/ISSUE_TEMPLATE/docs.yml b/.github/ISSUE_TEMPLATE/docs.yml new file mode 100644 index 0000000..c6602c1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs.yml @@ -0,0 +1,62 @@ +name: "\U0001F4DD Docs" +description: "Request an improvement to documentation" +title: "Docs: (fill in)" +labels: + - documentation +body: + - type: markdown + attributes: + value: By opening an issue, you agree to abide by the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). + - type: textarea + attributes: + label: Docs page(s) + description: | + What page(s) are you suggesting be changed or created? + placeholder: | + e.g. https://github.com/eslint/docker/blob/main/docs/rules/no-maintainer.md + validations: + required: true + - type: textarea + attributes: + label: What documentation issue do you want to solve? + description: | + Please explain your issue in as much detail as possible. + placeholder: | + The docs currently... + validations: + required: true + - type: textarea + attributes: + label: What do you think is the correct solution? + description: | + Please explain how you'd like to change the docs to address the problem. + placeholder: | + I'd like the docs to... + validations: + required: true + - type: checkboxes + attributes: + label: Participation + options: + - label: I am willing to submit a pull request for this change. + required: false + - type: markdown + attributes: + value: Please **do not** open a pull request until this issue has been accepted by the team. + - type: checkboxes + attributes: + label: AI acknowledgment + description: Check all that apply. + options: + - label: I did not use AI to generate this issue report. + required: false + - label: I used AI to translate the content of this issue report. + required: false + - label: I used AI to understand the codebase. + required: false + - label: I used AI to generate content for this issue report and I reviewed the generated content. + required: false + - type: textarea + attributes: + label: Additional comments + description: Is there anything else that's important for the team to know? diff --git a/.github/ISSUE_TEMPLATE/new-rule.yml b/.github/ISSUE_TEMPLATE/new-rule.yml new file mode 100644 index 0000000..5a28426 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/new-rule.yml @@ -0,0 +1,66 @@ +name: "\U0001F680 Propose a new rule" +description: "Propose a new rule to be added to the plugin" +title: "New Rule: (fill in)" +labels: + - rule + - feature +body: + - type: markdown + attributes: + value: By opening an issue, you agree to abide by the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). + - type: input + attributes: + label: Rule details + description: What should the new rule do? + validations: + required: true + - type: textarea + attributes: + label: Additional rule details + description: If there are any additional details about how the proposed rule should work, please provide them. + - type: dropdown + attributes: + label: What type of rule is this? + options: + - Warns about a potential problem + - Suggests an alternate way of doing something + validations: + required: true + - type: textarea + attributes: + label: Example code + description: Please provide some example code that this rule will warn about. + render: dockerfile + validations: + required: true + - type: textarea + attributes: + label: Prior Art + description: If this rule already exists in another Dockerfile linter (e.g. hadolint), please mention that here and provide link(s) to documentation. + render: markdown + - type: checkboxes + attributes: + label: Participation + options: + - label: I am willing to submit a pull request to implement this rule. + required: false + - type: markdown + attributes: + value: Please **do not** open a pull request until this issue has been accepted by the team. + - type: checkboxes + attributes: + label: AI acknowledgment + description: Check all that apply. + options: + - label: I did not use AI to generate this issue report. + required: false + - label: I used AI to translate the content of this issue report. + required: false + - label: I used AI to understand the codebase. + required: false + - label: I used AI to generate content for this issue report and I reviewed the generated content. + required: false + - type: textarea + attributes: + label: Additional comments + description: Is there anything else that's important for the team to know? diff --git a/.github/ISSUE_TEMPLATE/rule-change.yml b/.github/ISSUE_TEMPLATE/rule-change.yml new file mode 100644 index 0000000..a997db0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rule-change.yml @@ -0,0 +1,77 @@ +name: "\U0001F4DD Request a rule change" +description: "Request a change to an existing rule" +title: "Rule Change: (fill in)" +labels: + - enhancement + - rule +body: + - type: markdown + attributes: + value: By opening an issue, you agree to abide by the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). + - type: input + attributes: + label: What rule do you want to change? + validations: + required: true + - type: dropdown + attributes: + label: What change do you want to make? + options: + - Generate more warnings + - Generate fewer warnings + - Implement autofix + - Implement suggestions + validations: + required: true + - type: dropdown + attributes: + label: How do you think the change should be implemented? + options: + - A new option + - A new default behavior + - Other + validations: + required: true + - type: textarea + attributes: + label: Example code + description: Please provide some example code that this change will affect. + render: dockerfile + validations: + required: true + - type: textarea + attributes: + label: What does the rule currently do for this code? + validations: + required: true + - type: textarea + attributes: + label: What will the rule do after it's changed? + validations: + required: true + - type: checkboxes + attributes: + label: Participation + options: + - label: I am willing to submit a pull request to implement this change. + required: false + - type: markdown + attributes: + value: Please **do not** open a pull request until this issue has been accepted by the team. + - type: checkboxes + attributes: + label: AI acknowledgment + description: Check all that apply. + options: + - label: I did not use AI to generate this issue report. + required: false + - label: I used AI to translate the content of this issue report. + required: false + - label: I used AI to understand the codebase. + required: false + - label: I used AI to generate content for this issue report and I reviewed the generated content. + required: false + - type: textarea + attributes: + label: Additional comments + description: Is there anything else that's important for the team to know? diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000..13efb2d --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,4 @@ +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: ["github>eslint/workflows//.github/renovate/eslint-base.json5"], +} diff --git a/.github/workflows/add-to-triage.yml b/.github/workflows/add-to-triage.yml new file mode 100644 index 0000000..815fce6 --- /dev/null +++ b/.github/workflows/add-to-triage.yml @@ -0,0 +1,22 @@ +name: add-to-triage + +on: + issues: + types: + - opened + - reopened + - transferred + + pull_request_target: + types: + - opened + - reopened + +permissions: + contents: read + +jobs: + add-to-triage: + uses: eslint/workflows/.github/workflows/add-to-triage.yml@main + secrets: + project_bot_token: ${{ secrets.PROJECT_BOT_TOKEN }} diff --git a/.github/workflows/ci-bun.yml b/.github/workflows/ci-bun.yml new file mode 100644 index 0000000..bd58e8d --- /dev/null +++ b/.github/workflows/ci-bun.yml @@ -0,0 +1,17 @@ +name: ci-bun + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + ci-bun: + uses: eslint/workflows/.github/workflows/ci-bun.yml@main diff --git a/.github/workflows/ci-package-manager.yml b/.github/workflows/ci-package-manager.yml new file mode 100644 index 0000000..c61a7f8 --- /dev/null +++ b/.github/workflows/ci-package-manager.yml @@ -0,0 +1,17 @@ +name: ci-package-manager + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + ci-package-manager: + uses: eslint/workflows/.github/workflows/ci-package-manager.yml@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b2083e4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + verify: + name: Lint & Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: lts/* + - run: npm install + - run: npm run fmt:check + - run: npm run lint + + test: + name: Test (Node ${{ matrix.node }} on ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + node: [26.x, 25.x, 24.x, 22.x, 20.x, "20.19.0"] + include: + - os: windows-latest + node: "lts/*" + - os: macOS-latest + node: "lts/*" + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: ${{ matrix.node }} + # npm 10.9 and 11.5 and earlier fail to resolve this peer + # dependency graph ("Cannot read properties of null (reading + # 'edgesOut')"), and npm 12 does not support all of the Node.js + # versions in this matrix, so pin to the latest npm 11. + - run: npm install -g npm@11 + - run: npm install + - run: npm run build + - run: npm test diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..c7665ce --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,41 @@ +name: publish-release + +on: + workflow_dispatch: + inputs: + tag: + description: "Existing release tag to publish (e.g. docker-v0.1.1)" + required: true + type: string + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v7 + with: + ref: refs/tags/${{ inputs.tag }} + + - uses: actions/setup-node@v7 + with: + node-version: lts/* + registry-url: "https://registry.npmjs.org" + + - name: Verify tag matches package version + env: + TAG: ${{ inputs.tag }} + run: | + VERSION=$(node -p "require('./package.json').version") + if [ "$TAG" != "docker-v$VERSION" ]; then + echo "::error::Tag $TAG does not match package.json version $VERSION" + exit 1 + fi + + - name: Build and Publish + run: | + npm install + npm run build + npm publish --provenance diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..5edf05d --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,33 @@ +name: release-please + +on: + push: + branches: [main] + +jobs: + release-please: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5 + id: release + with: + token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }} + + - uses: actions/checkout@v7 + if: ${{ steps.release.outputs.release_created }} + + - uses: actions/setup-node@v7 + if: ${{ steps.release.outputs.release_created }} + with: + node-version: lts/* + registry-url: "https://registry.npmjs.org" + + - name: Build and Publish + run: | + npm install + npm run build + npm publish --provenance + if: ${{ steps.release.outputs.release_created }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..fe232e6 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,15 @@ +name: stale + +on: + schedule: + - cron: "31 22 * * *" # Runs every day at 10:31 PM UTC + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + uses: eslint/workflows/.github/workflows/stale.yml@main + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml new file mode 100644 index 0000000..34faff3 --- /dev/null +++ b/.github/workflows/update-readme.yml @@ -0,0 +1,16 @@ +name: update-readme + +on: + schedule: + - cron: "0 8 * * *" # Runs every day at 08:00 AM UTC + + workflow_dispatch: + +permissions: + contents: read + +jobs: + update-readme: + uses: eslint/workflows/.github/workflows/update-readme.yml@main + secrets: + workflow_push_bot_token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }} diff --git a/.gitignore b/.gitignore index 9dc13d6..d723aaf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,65 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Dependency directories node_modules/ -dist/ -coverage/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Output of 'npm pack' *.tgz + +# Yarn Integrity file +.yarn-integrity + +# VSCode +.vscode +*.code-workspace + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# eslint +.eslintcache + +# Lockfiles +package-lock.json +yarn.lock +bun.lockb +pnpm-lock.yaml + +# Build +dist/ + +# macOS .DS_Store + +# Automatically generated files by GitHub Actions workflow +/.shared-workflows diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..8783d62 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +package-lock = false +install-links = false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..bf315c6 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +dist +coverage +CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..466df71 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..f886573 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# ESLint Docker Language Plugin + +A Dockerfile language plugin for [ESLint](https://eslint.org), providing: + +- an ESLint-style **parser** for Dockerfiles (wrapping + [dockerfile-ast](https://www.npmjs.com/package/dockerfile-ast), the parser + behind Docker's official language server) that produces an ESTree-style + syntax tree, +- an ESLint **language** implementation so rules can traverse that tree, +- **rules** inspired by [hadolint](https://github.com/hadolint/hadolint) + checks and the + [Dockerfile best practices](https://docs.docker.com/build/building/best-practices/), + and +- a **recommended configuration**. + +## Installation + +```bash +npm install --save-dev eslint @eslint/docker +``` + +Requires Node.js `^20.19.0 || ^22.13.0 || >=24`. Tested with ESLint v10. + +## Development + +```bash +npm install +npm test # unit + integration tests (Vitest) +npm run lint # ESLint on the plugin's own sources +npm run fmt # Prettier +npm run build # compile TypeScript to dist/ +``` + +Pre-commit hooks (via [yorkie](https://www.npmjs.com/package/yorkie) and +lint-staged) run Prettier and ESLint on staged files. Releases are managed +with [release-please](https://github.com/googleapis/release-please) through +GitHub Actions. + +## License + +Apache-2.0 + + + + +## Sponsors + + diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..ba68a42 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,88 @@ +/** + * @fileoverview ESLint configuration file. + * @author Claude Fable 5 + */ + +//------------------------------------------------------------------------------ +// Imports +//------------------------------------------------------------------------------ + +import js from "@eslint/js"; +import eslintPlugin from "eslint-plugin-eslint-plugin"; +import tseslint from "typescript-eslint"; +import { defineConfig, globalIgnores } from "eslint/config"; + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const eslintPluginRulesRecommendedConfig = + eslintPlugin.configs["rules-recommended"]; +const eslintPluginTestsRecommendedConfig = + eslintPlugin.configs["tests-recommended"]; + +//------------------------------------------------------------------------------ +// Exports +//------------------------------------------------------------------------------ + +export default defineConfig( + globalIgnores(["dist/**", "coverage/**"]), + js.configs.recommended, + tseslint.configs.recommended, + { + files: ["**/*.ts"], + rules: { + "@typescript-eslint/no-unused-vars": [ + "error", + { argsIgnorePattern: "^_" }, + ], + }, + }, + { + files: ["src/rules/*.ts"], + ignores: ["src/rules/*.spec.ts", "src/rules/utils.ts"], + extends: [eslintPluginRulesRecommendedConfig], + rules: { + "eslint-plugin/require-meta-docs-recommended": "error", + "eslint-plugin/require-meta-schema": "off", // `schema` defaults to [] + "eslint-plugin/require-meta-schema-description": "off", + "eslint-plugin/prefer-placeholders": "error", + "eslint-plugin/prefer-replace-text": "error", + "eslint-plugin/report-message-format": [ + "error", + "^[^a-z].*\\.(?: \\([^()]*\\))?$", + ], + "eslint-plugin/require-meta-docs-description": [ + "error", + { pattern: "^(Enforce|Require|Disallow) .+[^. ]$" }, + ], + "eslint-plugin/require-meta-docs-url": [ + "error", + { + pattern: + "https://github.com/eslint/docker/blob/main/docs/rules/{{name}}.md", + }, + ], + }, + }, + { + files: ["src/rules/*.spec.ts"], + extends: [eslintPluginTestsRecommendedConfig], + rules: { + "eslint-plugin/test-case-property-ordering": [ + "error", + [ + "name", + "filename", + "code", + "output", + "language", + "options", + "languageOptions", + "errors", + ], + ], + "eslint-plugin/test-case-shorthand-strings": "error", + }, + }, +); diff --git a/package.json b/package.json new file mode 100644 index 0000000..670389e --- /dev/null +++ b/package.json @@ -0,0 +1,81 @@ +{ + "name": "@eslint/docker", + "version": "0.1.0", + "description": "Dockerfile language plugin for ESLint", + "license": "Apache-2.0", + "type": "module", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/eslint/docker.git" + }, + "keywords": [ + "eslint", + "eslint-plugin", + "docker", + "dockerfile", + "containerfile", + "hadolint", + "linting" + ], + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "scripts": { + "build": "tsc -p tsconfig.build.json", + "lint": "eslint .", + "fmt": "prettier --write .", + "fmt:check": "prettier --check .", + "test": "vitest run", + "test:watch": "vitest", + "test:coverage": "vitest run --coverage" + }, + "gitHooks": { + "pre-commit": "lint-staged" + }, + "lint-staged": { + "*.{js,ts}": [ + "prettier --write", + "eslint --fix" + ], + "*.{json,md,yml,yaml}": [ + "prettier --write" + ] + }, + "dependencies": { + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "dockerfile-ast": "^0.7.1" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@types/node": "~20.19.0", + "@vitest/coverage-v8": "^4.1.10", + "eslint": "^10.8.1", + "eslint-plugin-eslint-plugin": "^7.6.2", + "lint-staged": "^16.4.0", + "prettier": "^3.9.6", + "typescript": "^6.0.3", + "typescript-eslint": "^8.67.0", + "vitest": "^4.1.10", + "yorkie": "^2.0.0" + }, + "allowScripts": { + "yorkie": true + } +} diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..c334317 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,15 @@ +export default { + useTabs: true, + tabWidth: 4, + arrowParens: "avoid", + + overrides: [ + { + files: ["*.json"], + options: { + tabWidth: 2, + useTabs: false, + }, + }, + ], +}; diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..913de1c --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "extra-label": "triage:no", + "packages": { + ".": { + "release-type": "node", + "pull-request-title-pattern": "chore: release ${version} 🚀", + "extra-files": ["src/index.ts"] + } + } +} diff --git a/src/index.spec.ts b/src/index.spec.ts new file mode 100644 index 0000000..75d0b4b --- /dev/null +++ b/src/index.spec.ts @@ -0,0 +1,23 @@ +/** + * @fileoverview Tests for the plugin entry point. + * @author Claude Fable 5 + */ + +//------------------------------------------------------------------------------ +// Imports +//------------------------------------------------------------------------------ + +import { describe, expect, it } from "vitest"; +import plugin from "./index.js"; + +//------------------------------------------------------------------------------ +// Tests +//------------------------------------------------------------------------------ + +describe("plugin", () => { + it("should expose plugin metadata", () => { + expect(plugin.meta.name).toBe("@eslint/docker"); + expect(plugin.meta.namespace).toBe("docker"); + expect(plugin.meta.version).toMatch(/^\d+\.\d+\.\d+$/u); + }); +}); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..2d9800b --- /dev/null +++ b/src/index.ts @@ -0,0 +1,24 @@ +/** + * @fileoverview The @eslint/docker plugin: a Dockerfile language definition + * for ESLint, best-practice rules inspired by hadolint and the Docker + * documentation, and a recommended configuration. + * @author Claude Fable 5 + */ + +//------------------------------------------------------------------------------ +// Plugin +//------------------------------------------------------------------------------ + +const plugin = { + meta: { + name: "@eslint/docker", + namespace: "docker", + version: "0.1.0", // x-release-please-version + }, +}; + +//------------------------------------------------------------------------------ +// Exports +//------------------------------------------------------------------------------ + +export default plugin; diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..0543d12 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.spec.ts"] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5c732fd --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["ES2022"], + "strict": true, + "noUncheckedIndexedAccess": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "declaration": true, + "types": ["node"], + "noEmit": true + }, + "include": ["src/**/*.ts", "tests/**/*.ts", "vitest.config.ts"] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..6c64400 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,27 @@ +/** + * @fileoverview Vitest configuration file. + * @author Claude Fable 5 + */ + +//------------------------------------------------------------------------------ +// Imports +//------------------------------------------------------------------------------ + +import { defineConfig } from "vitest/config"; + +//------------------------------------------------------------------------------ +// Exports +//------------------------------------------------------------------------------ + +export default defineConfig({ + test: { + globals: true, + environment: "node", + include: ["src/**/*.spec.ts", "tests/**/*.test.ts"], + coverage: { + provider: "v8", + include: ["src/**/*.ts"], + exclude: ["src/**/*.spec.ts", "src/**/*.d.ts"], + }, + }, +}); From 376e8066a81aca8531e300080f3c30131b954f79 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Tue, 10 Nov 2026 18:14:49 -0500 Subject: [PATCH 2/6] chore: start at version 0.0.0 and release as 0.1.0 Co-Authored-By: Claude Fable 5.2 --- .release-please-manifest.json | 2 +- package.json | 2 +- release-please-config.json | 1 + src/index.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 466df71..e18ee07 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.0.0" } diff --git a/package.json b/package.json index 670389e..aa129c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eslint/docker", - "version": "0.1.0", + "version": "0.0.0", "description": "Dockerfile language plugin for ESLint", "license": "Apache-2.0", "type": "module", diff --git a/release-please-config.json b/release-please-config.json index 913de1c..2e8d43d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,6 +4,7 @@ "packages": { ".": { "release-type": "node", + "release-as": "0.1.0", "pull-request-title-pattern": "chore: release ${version} 🚀", "extra-files": ["src/index.ts"] } diff --git a/src/index.ts b/src/index.ts index 2d9800b..a5ff205 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ const plugin = { meta: { name: "@eslint/docker", namespace: "docker", - version: "0.1.0", // x-release-please-version + version: "0.0.0", // x-release-please-version }, }; From aa2e72587ab7d5d1e39c74f125a22d534d276700 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 11 Nov 2026 09:12:55 -0500 Subject: [PATCH 3/6] fix: build before packing Addresses Copilot review: npm pack on a fresh checkout produced a tarball without dist/. Co-Authored-By: Claude Opus 5.5 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index aa129c8..9fc164f 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ }, "scripts": { "build": "tsc -p tsconfig.build.json", + "prepack": "npm run build", "lint": "eslint .", "fmt": "prettier --write .", "fmt:check": "prettier --check .", From a790faef550fc4f6299b8f2ef76747bea7f78fb3 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 19 Nov 2026 12:17:20 -0500 Subject: [PATCH 4/6] chore: add author, bugs, and homepage to package.json Co-Authored-By: Claude Opus 5.5 --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 9fc164f..94f23cd 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@eslint/docker", "version": "0.0.0", "description": "Dockerfile language plugin for ESLint", + "author": "Nicholas C. Zakas", "license": "Apache-2.0", "type": "module", "main": "dist/index.js", @@ -24,6 +25,10 @@ "type": "git", "url": "git+https://github.com/eslint/docker.git" }, + "bugs": { + "url": "https://github.com/eslint/docker/issues" + }, + "homepage": "https://github.com/eslint/docker#readme", "keywords": [ "eslint", "eslint-plugin", From 322bd7fb7f37125cbd73e1389c3a0b2364505d7e Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 20 Nov 2026 10:35:41 -0500 Subject: [PATCH 5/6] ci: check out the released commit before publishing Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-please.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 5edf05d..32e88b9 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -18,6 +18,8 @@ jobs: - uses: actions/checkout@v7 if: ${{ steps.release.outputs.release_created }} + with: + ref: ${{ steps.release.outputs.sha }} - uses: actions/setup-node@v7 if: ${{ steps.release.outputs.release_created }} From b7ca7b157f8e88779fd4c29c210aaaab3b857358 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Mon, 23 Nov 2026 14:05:15 -0500 Subject: [PATCH 6/6] ci: only publish when the release commit triggered the run Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-please.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 32e88b9..6382f0f 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -16,10 +16,23 @@ jobs: with: token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }} + # npm provenance records the commit that triggered this run, so + # only publish when that is the commit being released. + - name: Verify release commit + if: ${{ steps.release.outputs.release_created }} + env: + RELEASE_SHA: ${{ steps.release.outputs.sha }} + run: | + if [ "$RELEASE_SHA" != "$GITHUB_SHA" ]; then + echo "::error::Release commit $RELEASE_SHA differs from $GITHUB_SHA; publish it manually." + exit 1 + fi + - uses: actions/checkout@v7 if: ${{ steps.release.outputs.release_created }} with: ref: ${{ steps.release.outputs.sha }} + persist-credentials: false - uses: actions/setup-node@v7 if: ${{ steps.release.outputs.release_created }}