-
Notifications
You must be signed in to change notification settings - Fork 671
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.