-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables with: ``` enabled: - pre-commit-hooks@4.4.0: commands: - end-of-file-fixer ```
- Loading branch information
1 parent
f5dcd5b
commit 6a633c3
Showing
6 changed files
with
63 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Pre-Commit-Hooks | ||
|
||
The set of formatter and linters in this suite are disabled by default. Some of the | ||
linters/formatters have different conflicting outputs. | ||
|
||
To enabled, add the list of checks you want in your trunk.yaml as such: | ||
|
||
```yaml | ||
lint: | ||
enabled: | ||
- pre-commit-hooks@4.4.0: | ||
commands: | ||
- end-of-file-fixer | ||
``` |
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,21 @@ | ||
version: 0.1 | ||
lint: | ||
definitions: | ||
- name: pre-commit-hooks | ||
known_good_version: 4.4.0 | ||
runtime: python | ||
package: pre-commit-hooks | ||
suggest_if: never | ||
environment: | ||
- name: PATH | ||
list: ["${env.PATH}"] | ||
commands: | ||
- name: end-of-file-fixer | ||
enabled: false | ||
output: rewrite | ||
in_place: true | ||
formatter: true | ||
run: end-of-file-fixer ${target} | ||
success_codes: [0, 1] | ||
files: | ||
- ALL |
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,19 @@ | ||
import { linterFmtTest, TestCallback } from "tests"; | ||
|
||
// Due to sqlfluff's fix subcommand being disabled by default, we need to manually enable it in the trunk.yaml. | ||
const fmtCallbacks: TestCallback = (driver) => { | ||
const trunkYamlPath = ".trunk/trunk.yaml"; | ||
const currentContents = driver.readFile(trunkYamlPath); | ||
const sqlfluffRegex = /- pre-commit-hooks@(.+)\n/; | ||
const newContents = currentContents.replace( | ||
sqlfluffRegex, | ||
"- pre-commit-hooks@$1:\n commands: [end-of-file-fixer]\n", | ||
); | ||
driver.writeFile(trunkYamlPath, newContents); | ||
}; | ||
|
||
linterFmtTest({ | ||
linterName: "pre-commit-hooks", | ||
namedTestPrefixes: ["end-of-file-fixer"], | ||
preCheck: fmtCallbacks, | ||
}); |
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 @@ | ||
This is a file without a new line |
6 changes: 6 additions & 0 deletions
6
linters/pre-commit-hooks/test_data/pre_commit_hooks_v4.4.0_end-of-file-fixer.fmt.shot
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,6 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing formatter pre-commit-hooks test end-of-file-fixer 1`] = ` | ||
"This is a file without a new line | ||
" | ||
`; |
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