Skip to content

Commit 8235b63

Browse files
authored
ci: Integrate prettier formatting (#376)
So far, the code formatting was not checked by the CI. Now it is. To do so, this commit introduces a new `format-check` npm command. I did not use the `eslint-prettier` plugin because the guidance on https://prettier.io/docs/en/integrating-with-linters.html recommends against doing so.
1 parent 4f1057d commit 8235b63

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

.bazelci/presubmit.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ tasks:
1818
- npm ci
1919
- npm run compile
2020
- npm run check-lint
21-
# TODO(allevato): Add a prettier check to verify that *.ts files don't
22-
# differ from their prettier output. We need `prettier-tslint` so that
23-
# prettier will obey our tslint config, but it doesn't support
24-
# Typescript 3 yet.
25-
# (https://github.com/azz/prettier-tslint/issues/18)
21+
- npm run format-check
2622
build_targets:
2723
- "//:dummy_target_for_ci"

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.json
2+
src/protos/protos.js

eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,6 @@ module.exports = tseslint.config(
182182
rules: {
183183
// Re-enable as soon as we are using ES modules for this config file.
184184
"@typescript-eslint/no-var-requires": "off",
185-
}
186-
});
185+
},
186+
},
187+
);

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@
444444
"scripts": {
445445
"check-lint": "eslint .",
446446
"compile": "./scripts/build.sh",
447+
"format-check": "prettier --check .",
448+
"format-fix": "prettier --write .",
447449
"vscode:prepublish": "./scripts/build.sh",
448450
"watch": "./scripts/build.sh -watch"
449451
},
@@ -454,6 +456,7 @@
454456
"eslint": "^8.57.0",
455457
"eslint-config-prettier": "^9.1.0",
456458
"eslint-plugin-jsdoc": "^48.2.2",
459+
"prettier": "^3.2.5",
457460
"typescript": "^5.4.4",
458461
"typescript-eslint": "^7.5.0"
459462
},
@@ -465,4 +468,4 @@
465468
"vscode-uri": "^3.0.2",
466469
"which": "^4.0.0"
467470
}
468-
}
471+
}

src/completion-provider/bazel_completion_provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ function getAbsoluteLabel(
9090
}
9191

9292
export class BazelCompletionItemProvider
93-
implements vscode.CompletionItemProvider {
93+
implements vscode.CompletionItemProvider
94+
{
9495
private targets: string[] = [];
9596

9697
/**

0 commit comments

Comments
 (0)