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

fix: less noisy CSS unused rules #1466

Merged
merged 3 commits into from
Jan 17, 2017
Merged

fix: less noisy CSS unused rules #1466

merged 3 commits into from
Jan 17, 2017

Conversation

patrickhulce
Copy link
Collaborator

  • filter out duplicate stylesheets
  • don't report stylesheets that have no rules

addresses #1456

* filter out duplicate stylesheets
* don't report stylesheets that have no rules

addresses #1456
@patrickhulce
Copy link
Collaborator Author

R: @ebidel

FWIW, I still think flagging the sheets as duplicate is cleaner than not returning them at all, but I totally empathize with the unnecessary noisiness :)

@@ -101,6 +101,15 @@
font-size: 20px;
}
</style>

<style>
/* Empty on purpose */
Copy link
Contributor

Choose a reason for hiding this comment

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

/* PASS - Empty on purpose */

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

</style>

<style>
/* Just an import shouldn't show up */
Copy link
Contributor

Choose a reason for hiding this comment

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

PASS - Just an import...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -127,7 +132,7 @@ class UnusedCSSRules extends Audit {
const unusedRatio = (unused / usage.length) || 0;
const results = Object.keys(indexedSheets).map(sheetId => {
return UnusedCSSRules.mapSheetToResult(indexedSheets[sheetId]);
});
}).filter(Boolean);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't feel strongly about it, but .filter(n => n) would also filter out the falsey values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I guess this is a pattern I'm used to, but is there a reason we don't use Boolean anywhere? !! seems to be preferred for casting throughout.

@ebidel
Copy link
Contributor

ebidel commented Jan 13, 2017

As an example, here's a run from chromestatus.com. It has a bunch of duplicate sheets from shadow dom usage:

screen shot 2017-01-13 at 10 35 39 am

@patrickhulce
Copy link
Collaborator Author

PTAL :)

@ebidel ebidel merged commit ae89793 into master Jan 17, 2017
@ebidel ebidel deleted the css_rules_improvements branch January 17, 2017 20:42
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.

None yet

2 participants