Giter Club home page Giter Club logo

css-audit's Issues

Audits: Ability to specify groups of properties for property-values audit

For generating the HTML report, we need a way to specify groups of property-values for the reports. This was accomplished with the CLI table by re-running the command with different values, but for the HTML report, we want to get the audit data for multiple groups at one time. One idea for accomplishing this is to specify an external JSON config file that contains the groups of properties to be audited, and that can be passed to the property-values option to process.

A related need is for a higher level grouping of the output of the --property-values audit. For example, we would want the output of these audits to be under a "Typography" heading in the HTML report:

--property-values=font-size
--property-values=line-height
--property-values=font-weight

And similarly, these we might want to have under "Spacing":

--property-values=padding,padding-top,padding-bottom,padding-left,padding-right
--property-values=margin,margin-top,margin-bottom,margin-left,margin-right

This could also be accomplished with the external config approach, but maybe there are other ideas!

Audit Idea: Detect repeated rules in the CSS

If we run this over a file, it should pull out any place where a property: value; repeats. For example, this should return [ 'border: 1px solid red' ].

.foo {
    padding: 20px;
    border: 1px solid red;
}
.bar {
    padding: 10px;
    border: 1px solid red;
}

Audit update action is not updating the HTML report

Because trunk is protected now, the action bot can't commit to it.

Error: Error: Pushing to https://github.com/WordPress/css-audit
POST git-receive-pack (735 bytes)
remote: error: GH006: Protected branch update failed for refs/heads/trunk.        
remote: error: At least 1 approving review is required by reviewers with write access.        
error: failed to push some refs to 'https://github.com/WordPress/css-audit'

Colors Audit: Check that only colors in the palette are used

This is an idea to improve the colors audit. Core has a fixed color palette, so we could use that list to highlight colors that are not in the set (if any). The palette should work like an allowed-list, flagging anything not on the list.

For example: if #f00 is added, it will show up in the audit, but currently no indication that it shouldn't be there. There could be another section of the Colors report, which lists these non-allowed-list colors:

  1. #f00 found in wordpress/src/wp-admin/css/admin-menu.css, line #33.

Formatter: JSON output should return all counts

In most audits, it shows "Top 10 most used …". This was done to avoid overwhelming the CLI screen from too much information, given how large the results can be on core CSS (even just single reports, like colors).

For the new JSON output (--format=json), this does not need to be human readable, so we can return the full result set for all values.

This might need to change the way audits return report objects.

Use a config file to configure audit options

This came out of discussion around #7, but is a larger idea, hence new issue. The arguments we can pass via CLI are pretty long and generally not very clear. Instead, what if we had a config file (akin to webpack.config.js/eslintrc.js) to set up those rules? It could be a JS/JSON file that describes the desired report (format, audits, etc).

I'm thinking something like this for format, which kind of follows a babel-ish pattern for audits, where you can say the string name of the audit, or an array with the first item as the name, and second as arguments to the audit. This would also address the issue in #7 by allowing for repeating audits with different arguments.

Example:

{
	"format": "html",
	"filename": "wp-admin",
	"audits": [
		"colors",
		"important",
		"display-none",
		"selectors",
		"media-queries",
		[
			"property-values",
			{
				"options": [ "font-size" ]
			}
		],
		[
			"property-values",
			{
				"options": [
					"padding-top",
					"padding-bottom",
					"padding-left",
					"padding-right"
				]
			}
		]
	]
}

We could also allow for a simple file like this— though maybe we should rename all & recommended to preset:all & preset:recommended.

{
	"format": "cli-table",
	"audits": "recommended"
}

New Audit: Media queries

  • Number of distinct media queries
  • Instance counts of each
  • [Maybe] Distinct sizes (ignoring if there's screen and …)
  • [Maybe] Flag any media queries that are the same except for screen?

Store audit data on Github (this repo?)

We need get all of the counts again without the .css.orig files, and we could update the Google Doc with the new counts, but it seems like we would benefit from having this data on Github so it is more shareable and we can keep track of history – is that something that could be part of this repo?

In order to automate this vs. manually copy/pasting the data as in the GDoc, it could work something like this (starting to test this out in this WIP PR):

  • Refactor to return an object of the results that can be used in other scripts
  • Refactor to move the CLI-specific contents to a cli.js
  • Create a new CLI argument - css-audit ./wp-admin/* --all --generate-report=wp-admin
  • --generate-report will output the audit results to an .html file inside public/wp-admin.html

Then public/ can be deployed on Github pages. Thoughts?

Automate WP core report generation

We'll want to keep the report up to date, so we should have some way of automatically regenerating the HTML report.

I'm assuming this will be a github action, but the trigger mechanism might need some thought. We'll want to update either on a fixed schedule, or after commits to WordPress/wordpress-develop, and after changes to this repo.

Past work committing back to the repo in a github action: https://github.com/WordPress/twentytwentyone/blob/trunk/.github/workflows/build.yml

Tests

Some tests to make sure the audits are counting things correctly would be good

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.