Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ named `testdata` so the Go tool ignores it, and it is in the justfile's
Fix a finding by changing the code, or by narrowing the rule if the finding
turns out to be a rule bug - never by loosening what the rule means.

`tailwind-v4-utilities` keeps vertical form spacing on flex-column gaps and
preserves forced-colors focus outlines with `outline-hidden`. It rejects the
earlier utility names whose behavior changed in Tailwind 4.

`unapproved-entity-autocreate` (`checks/semgrep/service-go.yml`) ships without
its `ensure$ANY(...)` branch on purpose: officer's `ensureAccount` /
`ensureLimitAccount` / `ensureAutoCreatedAsset` family in
Expand Down
27 changes: 27 additions & 0 deletions checks/semgrep/tailwind-v4-utilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright The Pit Project Owners. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Please see https://officer.openpit.dev and the OWNERS file for details.

rules:
- id: tailwind-v4-utilities
message: Use flex-column gap spacing and outline-hidden to retain Tailwind v3 layout and focus behavior.
severity: ERROR
languages: [generic]
pattern-regex: '(?<![\w-])(?:space-y-(?:[0-9.]+|\[[^\]\r\n]+\])|outline-none)(?![\w-])'
paths:
include: ["/web/src/**"]
exclude: ["/checks/semgrep/testdata/**"]

26 changes: 26 additions & 0 deletions checks/semgrep/testdata/tailwind-v4-utilities.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright The Pit Project Owners. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Please see https://officer.openpit.dev and the OWNERS file for details.

// ruleid: tailwind-v4-utilities
const oldSpacing = "space-y-2";
// ruleid: tailwind-v4-utilities
const oldFocus = "focus:outline-none";
// ok: tailwind-v4-utilities
const spacing = "flex flex-col gap-y-2";
// ok: tailwind-v4-utilities
const focus = "focus:outline-hidden";

1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ check-semgrep: install-semgrep
{{ semgrep }} --test --config checks/semgrep/file-header-site-link.yml --metrics=off --disable-version-check checks/semgrep/testdata/file-header-site-link.txt
{{ semgrep }} --test --config checks/semgrep/panel-access-reuse.yml --metrics=off --disable-version-check checks/semgrep/testdata/panel-access-reuse.tsx
{{ semgrep }} --test --config checks/semgrep/no-legacy-database-probe.yml --metrics=off --disable-version-check checks/semgrep/testdata/no-legacy-database-probe.go
{{ semgrep }} --test --config checks/semgrep/tailwind-v4-utilities.yml --metrics=off --disable-version-check checks/semgrep/testdata/tailwind-v4-utilities.tsx

# Lint all.
[parallel]
Expand Down
Loading
Loading