Skip to content

Lint feature descriptions with Vale #3045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
cache: npm
- run: npm ci
- run: npm test
vale:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: errata-ai/vale-action@d89dee975228ae261d22c15adcd03578634d429c # v2.1.1
with:
fail_on_error: true
version: 3.12.0

env:
FORCE_COLOR: 3
6 changes: 6 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
StylesPath = .vale

[features/*.yml]
View = features
BasedOnStyles = Vale, web-features-styles
Vale.Spelling = NO
5 changes: 5 additions & 0 deletions .vale/config/views/features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
engine: dasel
scopes:
- name: description
expr: description
type: md
6 changes: 6 additions & 0 deletions .vale/web-features-styles/Avoid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: existence
message: Consider removing '%s'
level: warning
ignorecase: true
tokens:
- is used to
9 changes: 9 additions & 0 deletions .vale/web-features-styles/Substitute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: substitution
message: Consider using '%s' instead of '%s'
level: warning
ignorecase: false
# swap maps tokens in form of bad: good
swap:
defines: sets
specifies: sets
determines: sets
13 changes: 13 additions & 0 deletions docs/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ The identifier should match the name, with these additional guidelines:

## Descriptions

> [!TIP]
> Some description rules are enforced by linting with Vale.
> A workflow reviews files that you change in your pull request and suggest changes.
> To run the Vale linter locally, [install Vale](https://vale.sh/docs/install) and run `vale .` from the root of the repository.

The `description` field contains a short description of the feature in Markdown-formatted text, which is converted to HTML in the published package.
Follow the general writing guidelines in this section, but see the [word and phrase list](#word-and-phrase-list) for specific usage instructions.

Expand Down Expand Up @@ -158,12 +163,16 @@ Avoid.
See [sets](#sets).
([#727](https://github.com/web-platform-dx/web-features/pull/727#discussion_r1537635491))

⚠️ Warned by vale: [`Substitute.yml`](/.vale/web-features-styles/Substitute.yml)

#### determines

Avoid.
See [sets](#sets).
([#727](https://github.com/web-platform-dx/web-features/pull/727#discussion_r1537635491))

⚠️ Warned by vale: [`Substitute.yml`](/.vale/web-features-styles/Substitute.yml)

#### device

Use "device" to refer to the underlying operating system or hardware environment, or combination thereof.
Expand Down Expand Up @@ -195,6 +204,8 @@ Omit "is used" where there's no loss in meaning.
For example, prefer "The feature reads…" over "The feature is used to read…"
([#727](https://github.com/web-platform-dx/web-features/pull/727#discussion_r1537635981))

✅ Required by vale: [`Avoid.yml`](/.vale/web-features-styles/Avoid.yml)

#### longhands and shorthands

Use the terms "shorthand" and "longhand" to describe the relationship between CSS properties that combine multiple properties into a single declaration and the individual properties.
Expand Down Expand Up @@ -231,6 +242,8 @@ Avoid.
See [sets](#sets).
([#727](https://github.com/web-platform-dx/web-features/pull/727#discussion_r1537635491))

⚠️ Warned by vale: [`Substitute.yml`](/.vale/web-features-styles/Substitute.yml)

#### styling … as … by default

Use this phrase (or using another appropriate preposition, such as "styling in") to note conventional or standardized default styling.
Expand Down
2 changes: 1 addition & 1 deletion features/beforeunload.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: beforeunload
description: "The `beforeunload` event is fired when the current window is about to be unloaded. Typically this is used to display a dialog to confirm if users really want to leave the page when there is unsaved data that would be lost."
description: "The `beforeunload` event is fired when the current window is about to be unloaded. Typically you use this to display a dialog to confirm if users really want to leave the page when there is unsaved data that would be lost."
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and several other feature changes) fix warnings or errors from Vale.

spec: https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-beforeunloadevent-interface
status:
compute_from: api.Window.beforeunload_event
Expand Down
2 changes: 1 addition & 1 deletion features/charset.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "@charset"
description: The `@charset` CSS at-rule specifies the character encoding of an external style sheet.
description: The `@charset` CSS at-rule specifies the character encoding of an external style sheet.

Check warning on line 2 in features/charset.yml

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [web-features-styles.Substitute] Consider using 'sets' instead of 'specifies' Raw Output: {"message": "[web-features-styles.Substitute] Consider using 'sets' instead of 'specifies'", "location": {"path": "features/charset.yml", "range": {"start": {"line": 2, "column": 41}}}, "severity": "WARNING"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this file so it would get flagged on review. Before merging, I ought to undo this change, to show I'm just ignoring this suggestion.

spec: https://drafts.csswg.org/css2/#charset
group: css
compat_features:
Expand Down
2 changes: 1 addition & 1 deletion features/del.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: <del>
description: The `<del>` element element represents a range of text that has been deleted from a document, styling text as strikethrough by default.
description: The `<del>` element element represents a range of text that has been deleted from a document, styling text as strikethrough by default.

Check failure on line 2 in features/del.yml

View workflow job for this annotation

GitHub Actions / vale

[vale] reported by reviewdog 🐶 [Vale.Repetition] 'element' is repeated! Raw Output: {"message": "[Vale.Repetition] 'element' is repeated!", "location": {"path": "features/del.yml", "range": {"start": {"line": 2, "column": 26}}}, "severity": "ERROR"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this file so it would get flagged on review. Before merging, I ought to push a change fixing it.

spec: https://html.spec.whatwg.org/multipage/edits.html#the-del-element
group: html-elements
compat_features:
Expand Down
2 changes: 1 addition & 1 deletion features/font-kerning.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: font-kerning
description: The `font-kerning` CSS property sets whether kerning data from a font is used to adjust the space between letters.
description: The `font-kerning` CSS property sets whether to use kerning data from a font to adjust the space between letters.
spec: https://drafts.csswg.org/css-fonts-4/#font-kerning-prop
group: font-features
caniuse: font-kerning
2 changes: 1 addition & 1 deletion features/form-associated-custom-elements.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Form-associated custom elements
description: Custom elements may act like built-in form elements, via the the `attachInternals()` method of `HTMLElement` and the `ElementInternals` API.
description: Custom elements may act like built-in form elements, via the `attachInternals()` method of `HTMLElement` and the `ElementInternals` API.
spec: https://html.spec.whatwg.org/multipage/custom-elements.html#form-associated-custom-elements
group:
- custom-elements
Expand Down
2 changes: 1 addition & 1 deletion features/hidden-until-found.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hidden="until-found"
description: 'The `hidden="until-found"` attribute hides an element until it is found using the browser''s find-in-page search or it is directly navigated to by following a URL fragment.'
description: The `hidden="until-found"` attribute hides an element until it is found using the browser's find-in-page search or it is directly navigated to by following a URL fragment.
spec: https://html.spec.whatwg.org/multipage/interaction.html#attr-hidden-until-found
group: html
compat_features:
Expand Down
2 changes: 1 addition & 1 deletion features/idle-detection.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: Idle detection
description: The `IdleDetector` API is used to notify a webpage of the user's idle, active, and locked state.
description: The `IdleDetector` API notifies a webpage of the user's idle, active, and locked state.
spec: https://wicg.github.io/idle-detection/
2 changes: 1 addition & 1 deletion features/ins.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: <ins>
description: The `<ins>` element element represents a range of text that has been inserted into a document, styling text as underlined by default.
description: The `<ins>` element represents a range of text that has been inserted into a document, styling text as underlined by default.
spec: https://html.spec.whatwg.org/multipage/edits.html#the-ins-element
group: html-elements
# TODO - Removed until #1173 is resolved, these APIs are currently listed
Expand Down
2 changes: 1 addition & 1 deletion features/optional-catch-binding.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Optional catch binding
description: Omit the the binding parameter of a `catch` clause when you don't need information about the exception in a `try ... catch` statement.
description: Omit the binding parameter of a `catch` clause when you don't need information about the exception in a `try ... catch` statement.
spec: https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-try-statement
group: javascript
snapshot: ecmascript-2019
Expand Down
2 changes: 1 addition & 1 deletion features/print-events.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Print events
description: An alternative to `@media print` queries, the `beforeprint` and `afterprint` events allow you to change the page for printing and and restore the page after printing.
description: An alternative to `@media print` queries, the `beforeprint` and `afterprint` events allow you to change the page for printing and restore the page after printing.
group: print
spec:
- https://html.spec.whatwg.org/multipage/indices.html#event-afterprint
Expand Down
Loading