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

Conversation

alrra
Copy link
Contributor

@alrra alrra commented Sep 7, 2017

Fix #136

Copy link
Member

@molant molant left a comment

Choose a reason for hiding this comment

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

In the docs you said:

if it's over 12 characters also have a short_name member that is at most 12 characters.

but in the tests you have a few cases where name <= 12, short_name is declared and the test passes.

It is not clear in the examples that fail if it should fail or not. IMO it should because it is not needed.


### 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.

// Requirements
// ------------------------------------------------------------------------------

const { ucs2 } = require('punycode');
Copy link
Member

Choose a reason for hiding this comment

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

punycode is deprecated
We should use Punycode.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using Punycode.js, just that it should be a dependency not a devDependency.

Copy link
Member

Choose a reason for hiding this comment

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

For whatever reason I though we weren't using it before, I didn't see an update in package.json and I assumed the worst :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For whatever reason I though we weren't using it before,

We used to use it in a rule, but now it's only used in making sure we can use the correct amount of emoji in commit messages.

just that it should be a dependency not a devDependency.

Fixed.

const { ucs2 } = require('punycode');

import { debug as d } from '../../utils/debug';
import { IManifestFetchEnd, IResponse, IRule, IRuleBuilder } from '../../types'; // eslint-disable-line no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

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

With the latest TS parsers you probably don't need the //eslint-disable-line no-unused-vars. I'm doing a PR that removes most of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove

Done.

// * it's specified
// * if `name` is over the `short_name` length limit

if (shortName || shortNameIsRequired) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this condition is right. Maybe something like this to make it clearer?

if (!shortName && !shortNameIsRequired) {
  return;
}

// There is something wrong with `shortName` so we need to check what it is
await checkIfDefined(resource, shortName, 'short_name'); 
await checkIfNonEmpty(resource, shortName, 'short_name');
await checkIfUnderLimit(resource, shortName, 'short_name', shortNameLengthLimit); 

},
{
name: `Manifest is specified with 'name' and 'short_name'`,
serverConfig: {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this test fail? name.length is <= 12

I don't see any reports

Copy link
Contributor Author

@alrra alrra Sep 8, 2017

Choose a reason for hiding this comment

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

No. If name is up to 12 characters, then it can be used instead ofshort_name. However, if short_name is also specified, it's perfectly valid, and not a problem.

Copy link
Member

Choose a reason for hiding this comment

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

This point of the documentation makes me think it should fail:

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

If they will just use name if less than 12 characters, then short_name shouldn't be there. If they can decide what to use depending on the context and the space (list of apps, title below and icon) then I think this phrase should be reformulated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then I think this phrase should be reformulated.

Any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

},
{
name: `Manifest is specified with 'name' and empty 'short_name'`,
reports: [{ message: `Manifest should contain non-empty 'short_name' member` }],
Copy link
Member

Choose a reason for hiding this comment

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

Also shouldn't it fail because short_name isn't needed?

serverConfig: {
'/': htmlWithManifestSpecified,
'/site.webmanifest': ''
}
},
{
name: `Web app manifest is specified and request for file fails`,
reports: [{ message: `Web app manifest file request failed` }],
name: `Manifest is specified and request for file fails`,
Copy link
Member

Choose a reason for hiding this comment

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

we should also say in the test name that we expect to pass in this case (and for similar ones where fetching the manifest fails).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@alrra
Copy link
Contributor Author

alrra commented Sep 8, 2017

@molant This PR is ready for another review.

```

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 i
Copy link
Contributor

Choose a reason for hiding this comment

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

won't make this rule fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@alrra alrra closed this in 78b6cb1 Sep 8, 2017
@alrra alrra deleted the fix-136 branch September 8, 2017 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants