Skip to content
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

New: Add rule to check the usage of web app manifest's short_name & name #498

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions docs/user-guide/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
## PWAs

* [`apple-touch-icons`](apple-touch-icons.md)
* [`manifest-app-name`](manifest-app-name.md)
* [`manifest-exists`](manifest-exists.md)
* [`manifest-file-extension`](manifest-file-extension.md)

Expand Down
119 changes: 119 additions & 0 deletions docs/user-guide/rules/manifest-app-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Require manifest to specify the web site/app name (`manifest-app-name`)

`manifest-app-name` warns against not specifying the web site/app's
name.

## Why is this important?

Browsers that have support for the [web app manifest file][manifest
spec] will use [`name`][manifest name] member (or the
[`short_name`][manifest short_name], when there is insufficient space)
to display the name of the site/app in situations such as: amongst
a list of other applications, as a label for an icon, etc.

If these members are not defined, browsers will try to get the name
from other sources such as the value of the [`application-name` meta
tag, `<title>`, or just default to a specific value (e.g.:
`Untitled`)][manifest metadata]. This can lead to bad user experience,
as the web site/app name may be truncated or just wrong.

In general it is recommended to specify and have the `name` member
under 30 character, and if it's over 12 characters also have a
`short_name` member that is at most 12 characters.

Notes:

* If the `name` is under or 12 characters, there isn't a need to
specify `short_name` as browsers can just use `name`.

* The 12 character limit is used to ensure that for most cases the
value won't be truncated. However depending on [other things][sonar
issue], such as:

* what font the user is using
* what characters the web site/app name includes (e.g. `i` occupies
less space then `W`)

the text may still be truncated even if it's under 12 characters.

* The 30 character limit is used in order to be consistent with the
native OSes/[app stores][app store] limits/recommendations.

## What does the rule check?

The rule checks if a non-empty `name` member was specified and it's
value is under 30 characters.

If the `name` member is over 12 characters, or `short_name` is
specified, the rule will also check if `short_name` has a non-empty
value that is under 12 characters.

### Examples that **trigger** the rule

Manifest is specified without `name` and `short_name`:

```json
{
...
}
```

Manifest is specified with a `name` longer than 12 characters
and no `short_name`:

```json
{
"name": "Baldwin Museum of Science",
...
}
```

Manifest is specified with a `name` longer than 30 characters:

```json
{
"name": "Baldwin Museum of Science - visit today!",
"short_name": "Baldwin"
...
}
```

Manifest is specified with `short_name` longer than 12 characters:

```json
{
"name": "Baldwin Museum of Science",
"short_name": "Baldwin Museum"
...
}
```

### Examples that **pass** the rule

Manifest is specified with a `name` shorter than 30 characters
Copy link
Member

Choose a reason for hiding this comment

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

Does not having a manifest pass the rule?
If so we should probably tell so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If so we should probably tell so.

Done.

and a `short_name` shorter than 12 characters:

```json
{
"name": "Baldwin Museum of Science",
"short_name": "Baldwin"
...
}
```

Note: [Not specifying a manifest file](manifest-exists.md), or having
an invalid one are covered by other rules, so those cases won't make
this rule fail.

## Further Reading

* [Web App Manifest specification][manifest spec]

<!-- Link labels: -->

[app store]: https://developer.apple.com/app-store/product-page/
[manifest metadata]: https://w3c.github.io/manifest/#authority-of-the-manifest%27s-metadata
[manifest name]: https://w3c.github.io/manifest/#name-member
[manifest short_name]: https://w3c.github.io/manifest/#short_name-member
[manifest spec]: https://w3c.github.io/manifest/
[sonar issue]: https://github.com/sonarwhal/sonar/issues/136
Loading