Compare commits

...
8 Commits
32 changed files with 289 additions and 232 deletions

No files matched your search

+7 -2
View File
@@ -11,6 +11,11 @@ on:
schedule: schedule:
- cron: '0 17 * * 5' - cron: '0 17 * * 5'
permissions:
actions: read
contents: read
security-events: write
jobs: jobs:
codeQL: codeQL:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
@@ -18,7 +23,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v6
with: with:
# Must fetch at least the immediate parents so that if this is # Must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head of the pull request. # a pull request then we can checkout the head of the pull request.
@@ -36,7 +41,7 @@ jobs:
uses: github/codeql-action/init@v4 uses: github/codeql-action/init@v4
# Override language selection by uncommenting this and choosing your languages # Override language selection by uncommenting this and choosing your languages
with: with:
language: 'javascript' languages: 'javascript-typescript'
- run: | - run: |
npm install npm install
+26 -18
View File
@@ -1,5 +1,6 @@
name: "build-and-test" name: "build-and-test"
on: # rebuild any PRs and main branch changes
on:
pull_request: pull_request:
branches: branches:
- main - main
@@ -7,22 +8,27 @@ on: # rebuild any PRs and main branch changes
branches: branches:
- main - main
permissions:
contents: read
jobs: jobs:
build: # make sure build/ci work properly # make sure build/ci work properly
build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- run: | - run: |
npm install npm install
npm run all npm run all
# Fail the build if there is dirty change # Fail the build if there are changes.
- run: git diff --exit-code -- dist - run: git diff --exit-code -- dist
test: # make sure the action works on a clean machine without building # make sure the action works on a clean machine without building
test:
needs: [ build ] needs: [ build ]
strategy: strategy:
matrix: matrix:
@@ -41,7 +47,7 @@ jobs:
contents: read contents: read
pull-requests: read pull-requests: read
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
@@ -51,10 +57,11 @@ jobs:
- uses: ./ - uses: ./
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: --timeout=5m --issues-exit-code=0 ./sample/... args: --timeout=5m --issues-exit-code=0 ./fixtures/simple/...
only-new-issues: true only-new-issues: true
test-go-install: # make sure the action works on a clean machine without building (go-install mode) # make sure the action works on a clean machine without building (go-install mode)
test-go-install:
needs: [ build ] needs: [ build ]
strategy: strategy:
matrix: matrix:
@@ -73,7 +80,7 @@ jobs:
contents: read contents: read
pull-requests: read pull-requests: read
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
@@ -83,7 +90,7 @@ jobs:
- uses: ./ - uses: ./
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
args: --timeout=5m --issues-exit-code=0 ./sample/... args: --timeout=5m --issues-exit-code=0 ./fixtures/simple/...
only-new-issues: true only-new-issues: true
install-mode: goinstall install-mode: goinstall
@@ -97,13 +104,13 @@ jobs:
- macos-latest - macos-latest
- windows-latest - windows-latest
wd: wd:
- sample-go-mod - fixtures/go-mod
- sample-go-tool - fixtures/go-tool
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
@@ -115,7 +122,8 @@ jobs:
working-directory: ${{ matrix.wd }} working-directory: ${{ matrix.wd }}
args: --timeout=5m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...
test-plugins: # make sure the action works on a clean machine with plugins # make sure the action works on a clean machine with plugins
test-plugins:
needs: [ build ] needs: [ build ]
strategy: strategy:
matrix: matrix:
@@ -134,7 +142,7 @@ jobs:
contents: read contents: read
pull-requests: read pull-requests: read
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
@@ -144,7 +152,7 @@ jobs:
- uses: ./ - uses: ./
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
working-directory: sample-plugins working-directory: fixtures/plugins
args: --timeout=5m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...
test-monorepo: test-monorepo:
@@ -161,7 +169,7 @@ jobs:
contents: read contents: read
pull-requests: read pull-requests: read
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 24.x node-version: 24.x
@@ -170,6 +178,6 @@ jobs:
go-version: oldstable go-version: oldstable
- uses: ./ - uses: ./
with: with:
working-directory: sample-monorepo working-directory: fixtures/monorepo
experimental: "automatic-module-directories" experimental: "automatic-module-directories"
args: --timeout=5m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...
+38 -15
View File
@@ -261,21 +261,22 @@ You will also likely need to add the following `.gitattributes` file to ensure t
### Overview ### Overview
| Option | Description | | Option | Description |
|---------------------------------------------------------------|----------------------------------------------------| |---------------------------------------------------------------|-------------------------------------------------------|
| [`version`](#version) | The version of golangci-lint to use. | | [`version`](#version) | The version of golangci-lint to use. |
| [`install-mode`](#install-mode) | The mode to install golangci-lint. | | [`version-file`](#version-file) | Gets the version of golangci-lint to use from a file. |
| [`install-only`](#install-only) | Only install golangci-lint. | | [`install-mode`](#install-mode) | The mode to install golangci-lint. |
| [`verify`](#verify) | Validates golangci-lint configuration file. | | [`install-only`](#install-only) | Only install golangci-lint. |
| [`github-token`](#github-token) | Used by the `only-new-issues` option. | | [`verify`](#verify) | Validates golangci-lint configuration file. |
| [`only-new-issues`](#only-new-issues) | Show only new issues. | | [`github-token`](#github-token) | Used by the `only-new-issues` option. |
| [`working-directory`](#working-directory) | The golangci-lint working directory. | | [`only-new-issues`](#only-new-issues) | Show only new issues. |
| [`args`](#args) | Golangci-lint command line arguments. | | [`working-directory`](#working-directory) | The golangci-lint working directory. |
| [`skip-cache`](#skip-cache) | Disable cache support. | | [`args`](#args) | Golangci-lint command line arguments. |
| [`skip-save-cache`](#skip-save-cache) | Don't save cache. | | [`skip-cache`](#skip-cache) | Disable cache support. |
| [`cache-invalidation-interval`](#cache-invalidation-interval) | Number of days before cache invalidation. | | [`skip-save-cache`](#skip-save-cache) | Don't save cache. |
| [`problem-matchers`](#problem-matchers) | Forces the usage of the embedded problem matchers. | | [`cache-invalidation-interval`](#cache-invalidation-interval) | Number of days before cache invalidation. |
| [Experimental](#experimental) | Experimental options | | [`problem-matchers`](#problem-matchers) | Forces the usage of the embedded problem matchers. |
| [Experimental](#experimental) | Experimental options |
### Installation ### Installation
@@ -302,6 +303,28 @@ with:
</details> </details>
#### `version-file`
Gets the version of golangci-lint to use from a file.
The path must be relative to the root of the project, or the `working-directory` if defined.
This parameter supports `.golangci-lint-version`, and `.tool-versions` files.
Only works with `install-mode: binary` (the default).
<details>
<summary>Example</summary>
```yml
uses: golangci/golangci-lint-action@v9
with:
version-file: .tool-versions
# ...
```
</details>
#### `install-mode` #### `install-mode`
(optional) (optional)
+7
View File
@@ -11,6 +11,13 @@ inputs:
- `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit. - `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
- `none`: the value is ignored. - `none`: the value is ignored.
required: false required: false
version-file:
description: |
Gets the version of golangci-lint to use from a file.
The path must be relative to the root of the project, or the `working-directory` if defined.
This parameter supports `.golangci-lint-version`, and `.tool-versions` files.
Only works with `install-mode: binary` (the default).
required: false
install-mode: install-mode:
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'." description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
default: "binary" default: "binary"
Generated Vendored
+32 -10
View File
@@ -97912,6 +97912,10 @@ const isLessVersion = (a, b) => {
}; };
const getRequestedVersion = () => { const getRequestedVersion = () => {
let requestedVersion = core.getInput(`version`); let requestedVersion = core.getInput(`version`);
let versionFilePath = core.getInput(`version-file`);
if (requestedVersion && versionFilePath) {
core.warning(`Both version (${requestedVersion}) and version-file (${versionFilePath}) inputs are specified, only version will be used`);
}
const workingDirectory = core.getInput(`working-directory`); const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod"; let goMod = "go.mod";
if (workingDirectory) { if (workingDirectory) {
@@ -97925,6 +97929,24 @@ const getRequestedVersion = () => {
core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`); core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`);
} }
} }
if (requestedVersion == "" && versionFilePath) {
if (workingDirectory) {
versionFilePath = path_1.default.join(workingDirectory, versionFilePath);
}
if (!fs.existsSync(versionFilePath)) {
throw new Error(`The specified golangci-lint version file at: ${versionFilePath} does not exist`);
}
const content = fs.readFileSync(versionFilePath, "utf-8");
if (path_1.default.basename(versionFilePath) === ".tool-versions") {
// asdf/mise file.
const match = content.match(/^golangci-lint\s+([^\n#]+)/m);
requestedVersion = match ? "v" + match[1].trim().replace(/^v/gi, "") : "";
}
else {
// .golangci-lint-version file.
requestedVersion = "v" + content.trim().replace(/^v/gi, "");
}
}
const parsedRequestedVersion = parseVersion(requestedVersion); const parsedRequestedVersion = parseVersion(requestedVersion);
if (parsedRequestedVersion == null) { if (parsedRequestedVersion == null) {
return null; return null;
@@ -102706,7 +102728,7 @@ function composeCollection(CN, ctx, token, props, onError) {
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType); let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
if (!tag) { if (!tag) {
const kt = ctx.schema.knownTags[tagName]; const kt = ctx.schema.knownTags[tagName];
if (kt && kt.collection === expType) { if (kt?.collection === expType) {
ctx.schema.tags.push(Object.assign({}, kt, { default: false })); ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
tag = kt; tag = kt;
} }
@@ -103592,7 +103614,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
}); });
if (!props.found) { if (!props.found) {
if (props.anchor || props.tag || value) { if (props.anchor || props.tag || value) {
if (value && value.type === 'block-seq') if (value?.type === 'block-seq')
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column'); onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
else else
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator'); onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
@@ -103809,7 +103831,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
} }
} }
else if (value) { else if (value) {
if ('source' in value && value.source && value.source[0] === ':') if ('source' in value && value.source?.[0] === ':')
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`); onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
else else
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`); onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
@@ -103853,7 +103875,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
const expectedEnd = isMap ? '}' : ']'; const expectedEnd = isMap ? '}' : ']';
const [ce, ...ee] = fc.end; const [ce, ...ee] = fc.end;
let cePos = offset; let cePos = offset;
if (ce && ce.source === expectedEnd) if (ce?.source === expectedEnd)
cePos = ce.offset + ce.source.length; cePos = ce.offset + ce.source.length;
else { else {
const name = fcName[0].toUpperCase() + fcName.substring(1); const name = fcName[0].toUpperCase() + fcName.substring(1);
@@ -105234,7 +105256,7 @@ const prettifyError = (src, lc) => (error) => {
if (/[^ ]/.test(lineStr)) { if (/[^ ]/.test(lineStr)) {
let count = 1; let count = 1;
const end = error.linePos[1]; const end = error.linePos[1];
if (end && end.line === line && end.col > col) { if (end?.line === line && end.col > col) {
count = Math.max(1, Math.min(end.col - col, 80 - ci)); count = Math.max(1, Math.min(end.col - col, 80 - ci));
} }
const pointer = ' '.repeat(ci) + '^'.repeat(count); const pointer = ' '.repeat(ci) + '^'.repeat(count);
@@ -105402,7 +105424,7 @@ class Alias extends Node.NodeBase {
data = anchors.get(source); data = anchors.get(source);
} }
/* istanbul ignore if */ /* istanbul ignore if */
if (!data || data.res === undefined) { if (data?.res === undefined) {
const msg = 'This should not happen: Alias anchor was not resolved?'; const msg = 'This should not happen: Alias anchor was not resolved?';
throw new ReferenceError(msg); throw new ReferenceError(msg);
} }
@@ -107744,7 +107766,7 @@ class Parser {
} }
*step() { *step() {
const top = this.peek(1); const top = this.peek(1);
if (this.type === 'doc-end' && (!top || top.type !== 'doc-end')) { if (this.type === 'doc-end' && top?.type !== 'doc-end') {
while (this.stack.length > 0) while (this.stack.length > 0)
yield* this.pop(); yield* this.pop();
this.stack.push({ this.stack.push({
@@ -108276,7 +108298,7 @@ class Parser {
do { do {
yield* this.pop(); yield* this.pop();
top = this.peek(1); top = this.peek(1);
} while (top && top.type === 'flow-collection'); } while (top?.type === 'flow-collection');
} }
else if (fc.end.length === 0) { else if (fc.end.length === 0) {
switch (this.type) { switch (this.type) {
@@ -110462,7 +110484,7 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
const num = typeof value === 'number' ? value : Number(value); const num = typeof value === 'number' ? value : Number(value);
if (!isFinite(num)) if (!isFinite(num))
return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf'; return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
let n = JSON.stringify(value); let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
if (!format && if (!format &&
minFractionDigits && minFractionDigits &&
(!tag || tag === 'tag:yaml.org,2002:float') && (!tag || tag === 'tag:yaml.org,2002:float') &&
@@ -110593,7 +110615,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`; ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`;
} }
if (valueStr === '' && !ctx.inFlow) { if (valueStr === '' && !ctx.inFlow) {
if (ws === '\n') if (ws === '\n' && valueComment)
ws = '\n\n'; ws = '\n\n';
} }
else { else {
Generated Vendored
+32 -10
View File
@@ -97912,6 +97912,10 @@ const isLessVersion = (a, b) => {
}; };
const getRequestedVersion = () => { const getRequestedVersion = () => {
let requestedVersion = core.getInput(`version`); let requestedVersion = core.getInput(`version`);
let versionFilePath = core.getInput(`version-file`);
if (requestedVersion && versionFilePath) {
core.warning(`Both version (${requestedVersion}) and version-file (${versionFilePath}) inputs are specified, only version will be used`);
}
const workingDirectory = core.getInput(`working-directory`); const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod"; let goMod = "go.mod";
if (workingDirectory) { if (workingDirectory) {
@@ -97925,6 +97929,24 @@ const getRequestedVersion = () => {
core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`); core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`);
} }
} }
if (requestedVersion == "" && versionFilePath) {
if (workingDirectory) {
versionFilePath = path_1.default.join(workingDirectory, versionFilePath);
}
if (!fs.existsSync(versionFilePath)) {
throw new Error(`The specified golangci-lint version file at: ${versionFilePath} does not exist`);
}
const content = fs.readFileSync(versionFilePath, "utf-8");
if (path_1.default.basename(versionFilePath) === ".tool-versions") {
// asdf/mise file.
const match = content.match(/^golangci-lint\s+([^\n#]+)/m);
requestedVersion = match ? "v" + match[1].trim().replace(/^v/gi, "") : "";
}
else {
// .golangci-lint-version file.
requestedVersion = "v" + content.trim().replace(/^v/gi, "");
}
}
const parsedRequestedVersion = parseVersion(requestedVersion); const parsedRequestedVersion = parseVersion(requestedVersion);
if (parsedRequestedVersion == null) { if (parsedRequestedVersion == null) {
return null; return null;
@@ -102706,7 +102728,7 @@ function composeCollection(CN, ctx, token, props, onError) {
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType); let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
if (!tag) { if (!tag) {
const kt = ctx.schema.knownTags[tagName]; const kt = ctx.schema.knownTags[tagName];
if (kt && kt.collection === expType) { if (kt?.collection === expType) {
ctx.schema.tags.push(Object.assign({}, kt, { default: false })); ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
tag = kt; tag = kt;
} }
@@ -103592,7 +103614,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
}); });
if (!props.found) { if (!props.found) {
if (props.anchor || props.tag || value) { if (props.anchor || props.tag || value) {
if (value && value.type === 'block-seq') if (value?.type === 'block-seq')
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column'); onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
else else
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator'); onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
@@ -103809,7 +103831,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
} }
} }
else if (value) { else if (value) {
if ('source' in value && value.source && value.source[0] === ':') if ('source' in value && value.source?.[0] === ':')
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`); onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
else else
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`); onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
@@ -103853,7 +103875,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
const expectedEnd = isMap ? '}' : ']'; const expectedEnd = isMap ? '}' : ']';
const [ce, ...ee] = fc.end; const [ce, ...ee] = fc.end;
let cePos = offset; let cePos = offset;
if (ce && ce.source === expectedEnd) if (ce?.source === expectedEnd)
cePos = ce.offset + ce.source.length; cePos = ce.offset + ce.source.length;
else { else {
const name = fcName[0].toUpperCase() + fcName.substring(1); const name = fcName[0].toUpperCase() + fcName.substring(1);
@@ -105234,7 +105256,7 @@ const prettifyError = (src, lc) => (error) => {
if (/[^ ]/.test(lineStr)) { if (/[^ ]/.test(lineStr)) {
let count = 1; let count = 1;
const end = error.linePos[1]; const end = error.linePos[1];
if (end && end.line === line && end.col > col) { if (end?.line === line && end.col > col) {
count = Math.max(1, Math.min(end.col - col, 80 - ci)); count = Math.max(1, Math.min(end.col - col, 80 - ci));
} }
const pointer = ' '.repeat(ci) + '^'.repeat(count); const pointer = ' '.repeat(ci) + '^'.repeat(count);
@@ -105402,7 +105424,7 @@ class Alias extends Node.NodeBase {
data = anchors.get(source); data = anchors.get(source);
} }
/* istanbul ignore if */ /* istanbul ignore if */
if (!data || data.res === undefined) { if (data?.res === undefined) {
const msg = 'This should not happen: Alias anchor was not resolved?'; const msg = 'This should not happen: Alias anchor was not resolved?';
throw new ReferenceError(msg); throw new ReferenceError(msg);
} }
@@ -107744,7 +107766,7 @@ class Parser {
} }
*step() { *step() {
const top = this.peek(1); const top = this.peek(1);
if (this.type === 'doc-end' && (!top || top.type !== 'doc-end')) { if (this.type === 'doc-end' && top?.type !== 'doc-end') {
while (this.stack.length > 0) while (this.stack.length > 0)
yield* this.pop(); yield* this.pop();
this.stack.push({ this.stack.push({
@@ -108276,7 +108298,7 @@ class Parser {
do { do {
yield* this.pop(); yield* this.pop();
top = this.peek(1); top = this.peek(1);
} while (top && top.type === 'flow-collection'); } while (top?.type === 'flow-collection');
} }
else if (fc.end.length === 0) { else if (fc.end.length === 0) {
switch (this.type) { switch (this.type) {
@@ -110462,7 +110484,7 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
const num = typeof value === 'number' ? value : Number(value); const num = typeof value === 'number' ? value : Number(value);
if (!isFinite(num)) if (!isFinite(num))
return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf'; return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
let n = JSON.stringify(value); let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
if (!format && if (!format &&
minFractionDigits && minFractionDigits &&
(!tag || tag === 'tag:yaml.org,2002:float') && (!tag || tag === 'tag:yaml.org,2002:float') &&
@@ -110593,7 +110615,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`; ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`;
} }
if (valueStr === '' && !ctx.inFlow) { if (valueStr === '' && !ctx.inFlow) {
if (ws === '\n') if (ws === '\n' && valueComment)
ws = '\n\n'; ws = '\n\n';
} }
else { else {
File renamed without changes.
@@ -1,4 +1,4 @@
module sample module github.com/golangci/sample
go 1.24.0 go 1.24.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
module sample module github.com/golangci/sample
go 1.24.0 go 1.24.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+115 -172
View File
@@ -22,10 +22,10 @@
"@types/which": "^3.0.4", "@types/which": "^3.0.4",
"tmp": "^0.2.5", "tmp": "^0.2.5",
"which": "^6.0.0", "which": "^6.0.0",
"yaml": "^2.8.1" "yaml": "^2.8.2"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.46.4", "@typescript-eslint/eslint-plugin": "^8.48.0",
"@typescript-eslint/parser": "^8.32.1", "@typescript-eslint/parser": "^8.32.1",
"@vercel/ncc": "^0.38.4", "@vercel/ncc": "^0.38.4",
"eslint": "^8.57.1", "eslint": "^8.57.1",
@@ -33,7 +33,7 @@
"eslint-plugin-import": "^2.32.0", "eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.4", "eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.6.2", "prettier": "^3.7.3",
"typescript": "^5.9.3" "typescript": "^5.9.3"
}, },
"engines": { "engines": {
@@ -528,6 +528,7 @@
"version": "5.2.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.0.tgz",
"integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==", "integrity": "sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==",
"peer": true,
"dependencies": { "dependencies": {
"@octokit/auth-token": "^4.0.0", "@octokit/auth-token": "^4.0.0",
"@octokit/graphql": "^7.1.0", "@octokit/graphql": "^7.1.0",
@@ -788,17 +789,17 @@
"integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==" "integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w=="
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.48.0.tgz",
"integrity": "sha512-R48VhmTJqplNyDxCyqqVkFSZIx1qX6PzwqgcXn1olLrzxcSBDlOsbtcnQuQhNtnNiJ4Xe5gREI1foajYaYU2Vg==", "integrity": "sha512-XxXP5tL1txl13YFtrECECQYeZjBZad4fyd3cFV4a19LkAY/bIp9fev3US4S5fDVV2JaYFiKAZ/GRTOLer+mbyQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.10.0", "@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.46.4", "@typescript-eslint/scope-manager": "8.48.0",
"@typescript-eslint/type-utils": "8.46.4", "@typescript-eslint/type-utils": "8.48.0",
"@typescript-eslint/utils": "8.46.4", "@typescript-eslint/utils": "8.48.0",
"@typescript-eslint/visitor-keys": "8.46.4", "@typescript-eslint/visitor-keys": "8.48.0",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^7.0.0", "ignore": "^7.0.0",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
@@ -812,7 +813,7 @@
"url": "https://opencollective.com/typescript-eslint" "url": "https://opencollective.com/typescript-eslint"
}, },
"peerDependencies": { "peerDependencies": {
"@typescript-eslint/parser": "^8.46.4", "@typescript-eslint/parser": "^8.48.0",
"eslint": "^8.57.0 || ^9.0.0", "eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0" "typescript": ">=4.8.4 <6.0.0"
} }
@@ -828,16 +829,17 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.48.0.tgz",
"integrity": "sha512-tK3GPFWbirvNgsNKto+UmB/cRtn6TZfyw0D6IKrW55n6Vbs7KJoZtI//kpTKzE/DUmmnAFD8/Ca46s7Obs92/w==", "integrity": "sha512-jCzKdm/QK0Kg4V4IK/oMlRZlY+QOcdjv89U2NgKHZk1CYTj82/RVSx1mV/0gqCVMJ/DA+Zf/S4NBWNF8GQ+eqQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.46.4", "@typescript-eslint/scope-manager": "8.48.0",
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"@typescript-eslint/typescript-estree": "8.46.4", "@typescript-eslint/typescript-estree": "8.48.0",
"@typescript-eslint/visitor-keys": "8.46.4", "@typescript-eslint/visitor-keys": "8.48.0",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@@ -853,14 +855,14 @@
} }
}, },
"node_modules/@typescript-eslint/project-service": { "node_modules/@typescript-eslint/project-service": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.48.0.tgz",
"integrity": "sha512-nPiRSKuvtTN+no/2N1kt2tUh/HoFzeEgOm9fQ6XQk4/ApGqjx0zFIIaLJ6wooR1HIoozvj2j6vTi/1fgAz7UYQ==", "integrity": "sha512-Ne4CTZyRh1BecBf84siv42wv5vQvVmgtk8AuiEffKTUo3DrBaGYZueJSxxBZ8fjk/N3DrgChH4TOdIOwOwiqqw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.46.4", "@typescript-eslint/tsconfig-utils": "^8.48.0",
"@typescript-eslint/types": "^8.46.4", "@typescript-eslint/types": "^8.48.0",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@@ -875,14 +877,14 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.48.0.tgz",
"integrity": "sha512-tMDbLGXb1wC+McN1M6QeDx7P7c0UWO5z9CXqp7J8E+xGcJuUuevWKxuG8j41FoweS3+L41SkyKKkia16jpX7CA==", "integrity": "sha512-uGSSsbrtJrLduti0Q1Q9+BF1/iFKaxGoQwjWOIVNJv0o6omrdyR8ct37m4xIl5Zzpkp69Kkmvom7QFTtue89YQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"@typescript-eslint/visitor-keys": "8.46.4" "@typescript-eslint/visitor-keys": "8.48.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -893,9 +895,9 @@
} }
}, },
"node_modules/@typescript-eslint/tsconfig-utils": { "node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.48.0.tgz",
"integrity": "sha512-+/XqaZPIAk6Cjg7NWgSGe27X4zMGqrFqZ8atJsX3CWxH/jACqWnrWI68h7nHQld0y+k9eTTjb9r+KU4twLoo9A==", "integrity": "sha512-WNebjBdFdyu10sR1M4OXTt2OkMd5KWIL+LLfeH9KhgP+jzfDV/LI3eXzwJ1s9+Yc0Kzo2fQCdY/OpdusCMmh6w==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -910,15 +912,15 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.48.0.tgz",
"integrity": "sha512-V4QC8h3fdT5Wro6vANk6eojqfbv5bpwHuMsBcJUJkqs2z5XnYhJzyz9Y02eUmF9u3PgXEUiOt4w4KHR3P+z0PQ==", "integrity": "sha512-zbeVaVqeXhhab6QNEKfK96Xyc7UQuoFWERhEnj3mLVnUWrQnv15cJNseUni7f3g557gm0e46LZ6IJ4NJVOgOpw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"@typescript-eslint/typescript-estree": "8.46.4", "@typescript-eslint/typescript-estree": "8.48.0",
"@typescript-eslint/utils": "8.46.4", "@typescript-eslint/utils": "8.48.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^2.1.0" "ts-api-utils": "^2.1.0"
}, },
@@ -935,9 +937,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.48.0.tgz",
"integrity": "sha512-USjyxm3gQEePdUwJBFjjGNG18xY9A2grDVGuk7/9AkjIF1L+ZrVnwR5VAU5JXtUnBL/Nwt3H31KlRDaksnM7/w==", "integrity": "sha512-cQMcGQQH7kwKoVswD1xdOytxQR60MWKM1di26xSUtxehaDs/32Zpqsu5WJlXTtTTqyAVK8R7hvsUnIXRS+bjvA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@@ -949,21 +951,20 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.48.0.tgz",
"integrity": "sha512-7oV2qEOr1d4NWNmpXLR35LvCfOkTNymY9oyW+lUHkmCno7aOmIf/hMaydnJBUTBMRCOGZh8YjkFOc8dadEoNGA==", "integrity": "sha512-ljHab1CSO4rGrQIAyizUS6UGHHCiAYhbfcIZ1zVJr5nMryxlXMVWS3duFPSKvSUbFPwkXMFk1k0EMIjub4sRRQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/project-service": "8.46.4", "@typescript-eslint/project-service": "8.48.0",
"@typescript-eslint/tsconfig-utils": "8.46.4", "@typescript-eslint/tsconfig-utils": "8.48.0",
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"@typescript-eslint/visitor-keys": "8.46.4", "@typescript-eslint/visitor-keys": "8.48.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
"minimatch": "^9.0.4", "minimatch": "^9.0.4",
"semver": "^7.6.0", "semver": "^7.6.0",
"tinyglobby": "^0.2.15",
"ts-api-utils": "^2.1.0" "ts-api-utils": "^2.1.0"
}, },
"engines": { "engines": {
@@ -1017,16 +1018,16 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.48.0.tgz",
"integrity": "sha512-AbSv11fklGXV6T28dp2Me04Uw90R2iJ30g2bgLz529Koehrmkbs1r7paFqr1vPCZi7hHwYxYtxfyQMRC8QaVSg==", "integrity": "sha512-yTJO1XuGxCsSfIVt1+1UrLHtue8xz16V8apzPYI06W0HbEbEWHxHXgZaAgavIkoh+GeV6hKKd5jm0sS6OYxWXQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.7.0", "@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.46.4", "@typescript-eslint/scope-manager": "8.48.0",
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"@typescript-eslint/typescript-estree": "8.46.4" "@typescript-eslint/typescript-estree": "8.48.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -1041,13 +1042,13 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "8.46.4", "version": "8.48.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.46.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.48.0.tgz",
"integrity": "sha512-/++5CYLQqsO9HFGLI7APrxBJYo+5OCMpViuhV8q5/Qa3o5mMrF//eQHks+PXcsAVaLdn817fMuS7zqoXNNZGaw==", "integrity": "sha512-T0XJMaRPOH3+LBbAfzR2jalckP1MSG/L9eUtY0DEzUyVaXJ/t6zN0nR7co5kz0Jko/nkSYCBRkz1djvjajVTTg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.46.4", "@typescript-eslint/types": "8.48.0",
"eslint-visitor-keys": "^4.2.1" "eslint-visitor-keys": "^4.2.1"
}, },
"engines": { "engines": {
@@ -1103,6 +1104,7 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
"dev": true, "dev": true,
"peer": true,
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -1344,19 +1346,6 @@
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
"node_modules/braces": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"dependencies": {
"fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/call-bind": { "node_modules/call-bind": {
"version": "1.0.8", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz",
@@ -1811,6 +1800,7 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
"integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1", "@eslint-community/regexpp": "^4.6.1",
@@ -1867,6 +1857,7 @@
"integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"bin": { "bin": {
"eslint-config-prettier": "bin/cli.js" "eslint-config-prettier": "bin/cli.js"
}, },
@@ -2135,36 +2126,6 @@
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
"dev": true "dev": true
}, },
"node_modules/fast-glob": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@nodelib/fs.stat": "^2.0.2",
"@nodelib/fs.walk": "^1.2.3",
"glob-parent": "^5.1.2",
"merge2": "^1.3.0",
"micromatch": "^4.0.8"
},
"engines": {
"node": ">=8.6.0"
}
},
"node_modules/fast-glob/node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"license": "ISC",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fast-json-stable-stringify": { "node_modules/fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@@ -2186,6 +2147,24 @@
"reusify": "^1.0.4" "reusify": "^1.0.4"
} }
}, },
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
"integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"picomatch": "^3 || ^4"
},
"peerDependenciesMeta": {
"picomatch": {
"optional": true
}
}
},
"node_modules/file-entry-cache": { "node_modules/file-entry-cache": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@@ -2198,19 +2177,6 @@
"node": "^10.12.0 || >=12.0.0" "node": "^10.12.0 || >=12.0.0"
} }
}, },
"node_modules/fill-range": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/find-up": { "node_modules/find-up": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
@@ -2831,16 +2797,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/is-number-object": { "node_modules/is-number-object": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz",
@@ -3122,30 +3078,6 @@
"node": ">= 0.4" "node": ">= 0.4"
} }
}, },
"node_modules/merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 8"
}
},
"node_modules/micromatch": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"dependencies": {
"braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
}
},
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.52.0", "version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@@ -3429,13 +3361,14 @@
"dev": true "dev": true
}, },
"node_modules/picomatch": { "node_modules/picomatch": {
"version": "2.3.1", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=8.6" "node": ">=12"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/jonschlinkert" "url": "https://github.com/sponsors/jonschlinkert"
@@ -3461,10 +3394,12 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "3.6.2", "version": "3.7.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.3.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "integrity": "sha512-QgODejq9K3OzoBbuyobZlUhznP5SKwPqp+6Q6xw6o8gnhr4O85L2U915iM2IDcfF2NPXVaM9zlo9tdwipnYwzg==",
"dev": true, "dev": true,
"license": "MIT",
"peer": true,
"bin": { "bin": {
"prettier": "bin/prettier.cjs" "prettier": "bin/prettier.cjs"
}, },
@@ -4026,6 +3961,23 @@
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true "dev": true
}, },
"node_modules/tinyglobby": {
"version": "0.2.15",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz",
"integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.5.0",
"picomatch": "^4.0.3"
},
"engines": {
"node": ">=12.0.0"
},
"funding": {
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
"node_modules/tmp": { "node_modules/tmp": {
"version": "0.2.5", "version": "0.2.5",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz",
@@ -4035,19 +3987,6 @@
"node": ">=14.14" "node": ">=14.14"
} }
}, },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/tr46": { "node_modules/tr46": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
@@ -4200,6 +4139,7 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@@ -4412,15 +4352,18 @@
} }
}, },
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.8.1", "version": "2.8.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
"integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==",
"license": "ISC", "license": "ISC",
"bin": { "bin": {
"yaml": "bin.mjs" "yaml": "bin.mjs"
}, },
"engines": { "engines": {
"node": ">= 14.6" "node": ">= 14.6"
},
"funding": {
"url": "https://github.com/sponsors/eemeli"
} }
}, },
"node_modules/yocto-queue": { "node_modules/yocto-queue": {
+3 -3
View File
@@ -40,10 +40,10 @@
"@types/which": "^3.0.4", "@types/which": "^3.0.4",
"tmp": "^0.2.5", "tmp": "^0.2.5",
"which": "^6.0.0", "which": "^6.0.0",
"yaml": "^2.8.1" "yaml": "^2.8.2"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.46.4", "@typescript-eslint/eslint-plugin": "^8.48.0",
"@typescript-eslint/parser": "^8.32.1", "@typescript-eslint/parser": "^8.32.1",
"@vercel/ncc": "^0.38.4", "@vercel/ncc": "^0.38.4",
"eslint": "^8.57.1", "eslint": "^8.57.1",
@@ -51,7 +51,7 @@
"eslint-plugin-import": "^2.32.0", "eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.5.4", "eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.6.2", "prettier": "^3.7.3",
"typescript": "^5.9.3" "typescript": "^5.9.3"
} }
} }
+27
View File
@@ -67,6 +67,12 @@ const isLessVersion = (a: Version, b: Version): boolean => {
const getRequestedVersion = (): Version => { const getRequestedVersion = (): Version => {
let requestedVersion = core.getInput(`version`) let requestedVersion = core.getInput(`version`)
let versionFilePath = core.getInput(`version-file`)
if (requestedVersion && versionFilePath) {
core.warning(`Both version (${requestedVersion}) and version-file (${versionFilePath}) inputs are specified, only version will be used`)
}
const workingDirectory = core.getInput(`working-directory`) const workingDirectory = core.getInput(`working-directory`)
let goMod = "go.mod" let goMod = "go.mod"
@@ -83,6 +89,27 @@ const getRequestedVersion = (): Version => {
} }
} }
if (requestedVersion == "" && versionFilePath) {
if (workingDirectory) {
versionFilePath = path.join(workingDirectory, versionFilePath)
}
if (!fs.existsSync(versionFilePath)) {
throw new Error(`The specified golangci-lint version file at: ${versionFilePath} does not exist`)
}
const content = fs.readFileSync(versionFilePath, "utf-8")
if (path.basename(versionFilePath) === ".tool-versions") {
// asdf/mise file.
const match = content.match(/^golangci-lint\s+([^\n#]+)/m)
requestedVersion = match ? "v" + match[1].trim().replace(/^v/gi, "") : ""
} else {
// .golangci-lint-version file.
requestedVersion = "v" + content.trim().replace(/^v/gi, "")
}
}
const parsedRequestedVersion = parseVersion(requestedVersion) const parsedRequestedVersion = parseVersion(requestedVersion)
if (parsedRequestedVersion == null) { if (parsedRequestedVersion == null) {
return null return null