-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mbwhite <[email protected]>
- Loading branch information
Showing
7 changed files
with
150 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
## API | ||
|
||
> note this is hasn't been extensively tested yet in alpha - focussing on the cli invocation | ||
#### `linter(globs: string[], config?: Config): Promise<Problem[]>` | ||
|
||
Runs the linter on the provided `globs`, and resolves to the list of found problems. | ||
Each problem has a `level` and a `message` property. `path` is the path to the | ||
original file, `loc` is an object which describes the location of the problem. | ||
|
||
An additional `config` object can be passed to fine-tune rules (see [Configuring `tekton-lint`](#configuring-tekton-lint)). | ||
|
||
```ts | ||
interface Problem { | ||
level: 'warning' | 'error'; | ||
message: string; | ||
path?: string; | ||
loc?: { | ||
range: [number, number]; | ||
startLine: number; | ||
startColumn: number; | ||
endLine: number; | ||
endColumn: number; | ||
}; | ||
} | ||
|
||
interface Config { | ||
rules: { | ||
[rule: string]: 'off' | 'warning' | 'error'; | ||
}; | ||
} | ||
``` | ||
|
||
##### Example | ||
|
||
```js | ||
const linter = require('tekton-lint'); | ||
|
||
const problems = await linter(['path/to/defs/**/*.yaml']); | ||
|
||
for (const problem of problems) { | ||
console.log(problem.level, problem.message) | ||
} | ||
``` | ||
|
||
#### `linter.lint(docs: any[], config?: Config): Problem[]` | ||
|
||
Runs the linter on the provided parsed documents. Returns the list of found problems. | ||
|
||
##### Example | ||
|
||
```js | ||
const linter = require('tekton-lint'); | ||
|
||
const problems = linter.lint([{ | ||
apiVersion: 'tekton.dev/v1beta1', | ||
kind: 'Task', | ||
metadata: { | ||
name: 'my-task', | ||
}, | ||
spec: { | ||
steps: [], | ||
}, | ||
}]); | ||
|
||
for (const problem of problems) { | ||
console.log(problem.level, problem.message) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## IDE Integration | ||
|
||
> note this is hasn't been extensively tested yet in alpha - focussing on the cli invocation | ||
`tekton-lint` can be added as a [Task][vscode-task]: | ||
|
||
```js | ||
// .vscode/tasks.json | ||
|
||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run tekton-lint in the workspace", | ||
"type": "shell", | ||
"command": "tekton-lint", | ||
"args": [ | ||
"--watch", | ||
"--format","vscode", | ||
"--config","${workspaceFolder}/.vscode/.tektonlintrc.yaml", // if needed, otherwise remove this line | ||
"${workspaceFolder}/**/*.yaml" // Change this path to the path of your yaml files (this will watch for every yaml file in your currently open workspace) | ||
], | ||
"problemMatcher": [ | ||
{ | ||
"fileLocation": "absolute", | ||
"pattern": [ | ||
{ | ||
"regexp": "^([^\\s].*):$", | ||
"file": 1 | ||
}, | ||
{ | ||
"regexp": "^(error|warning|info)\\s+\\((\\d+,\\d+,\\d+,\\d+)\\):(.*)$", | ||
"severity": 1, | ||
"location": 2, | ||
"message": 3, | ||
"loop": true | ||
} | ||
], | ||
"background": { | ||
"activeOnStart": true, | ||
"beginsPattern": "^File (.*) has been changed! Running Linter again!", | ||
"endsPattern": "^Tekton-lint finished running!" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
You can run this task from _Terminal_ > _Run Task..._ > _Run tekton-lint_: | ||
|
||
![vscode-screenshot] | ||
|
File renamed without changes
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters