Skip to content

Commit

Permalink
feat: stylelint (#341)
Browse files Browse the repository at this point in the history
* feat: demonstrate stylelint

follows https://github.com/aspect-build/rules_lint/blob/main/lint/README.md#step-1-run-linter-in-the-example

* feat: create stylelint linter aspect

Follows instructions: https://github.com/aspect-build/rules_lint/blob/main/lint/README.md#step-2-create-linter

* chore: add stylelint to README

* chore: cleanups for review

* chore: more code review cleanup
  • Loading branch information
alexeagle authored Jul 19, 2024
1 parent c1f179f commit f2007da
Show file tree
Hide file tree
Showing 16 changed files with 1,812 additions and 294 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ New tools are being added frequently, so check this page again!
| ---------------------- | --------------------- | ---------------- |
| C / C++ | [clang-format] | [clang-tidy] |
| Cuda | [clang-format] | |
| CSS, Less, Sass | [Prettier] | |
| CSS, Less, Sass | [Prettier] | [Stylelint] |
| Go | [gofmt] or [gofumpt] | |
| GraphQL | [Prettier] | |
| HCL (Hashicorp Config) | [terraform] fmt | |
Expand Down Expand Up @@ -73,6 +73,7 @@ New tools are being added frequently, so check this page again!
[vale]: https://vale.sh/
[yamlfmt]: https://github.com/google/yamlfmt
[rustfmt]: https://rust-lang.github.io/rustfmt
[stylelint]: https://stylelint.io

1. Non-hermetic: requires that a swift toolchain is installed on the machine.
See https://github.com/bazelbuild/rules_swift#1-install-swift
Expand Down
5 changes: 5 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ stardoc_with_diff_test(
bzl_library_target = "//format:defs",
)

stardoc_with_diff_test(
name = "stylelint",
bzl_library_target = "//lint:stylelint",
)

stardoc_with_diff_test(
name = "ruff",
bzl_library_target = "//lint:ruff",
Expand Down
113 changes: 113 additions & 0 deletions docs/stylelint.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/.aspect/cli/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ lint:
- //tools/lint:linters.bzl%flake8
- //tools/lint:linters.bzl%ktlint
- //tools/lint:linters.bzl%pmd
- //tools/lint:linters.bzl%stylelint
- //tools/lint:linters.bzl%ruff
- //tools/lint:linters.bzl%vale
5 changes: 5 additions & 0 deletions example/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ js_library(
],
)

js_library(
name = "stylelintrc",
srcs = ["stylelint.config.mjs"],
)

# NB: this alias does NOT cause Bazel's Loading phase to load the tools/BUILD file.
# That's important as we don't want users to wait for "Eager fetching" for ~EVERY language which
# that build file loads from.
Expand Down
2 changes: 1 addition & 1 deletion example/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ $machine == "Windows" ]; then
# avoid missing linters on windows platform
args=("--aspects=$(echo //tools/lint:linters.bzl%{flake8,pmd,ruff,vale,clang_tidy} | tr ' ' ',')")
else
args=("--aspects=$(echo //tools/lint:linters.bzl%{buf,eslint,flake8,ktlint,pmd,ruff,shellcheck,vale,clang_tidy} | tr ' ' ',')")
args=("--aspects=$(echo //tools/lint:linters.bzl%{buf,eslint,flake8,ktlint,pmd,ruff,shellcheck,stylelint,vale,clang_tidy} | tr ' ' ',')")
fi

# NB: perhaps --remote_download_toplevel is needed as well with remote execution?
Expand Down
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"eslint": "^9",
"prettier": "^2.8.7",
"prettier-plugin-sql": "^0.14.0",
"stylelint": "^16",
"typescript": "4.9.5",
"typescript-eslint": "^7.10.0"
},
Expand Down
Loading

0 comments on commit f2007da

Please sign in to comment.