Skip to content
This repository has been archived by the owner. It is now read-only.

WordPress VIP preset #1099

Closed
paulschreiber opened this issue Feb 21, 2015 · 19 comments

Comments

Projects
None yet
6 participants
@paulschreiber
Copy link

commented Feb 21, 2015

It would be helpful to have a WordPress VIP preset. Their style rules — based on jQuery — are here:
https://make.wordpress.org/core/handbook/coding-standards/javascript/

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 21, 2015

Right now the Idiomatic (referenced in the wordpress style guide) preset i'm working on is also based on jquery. Shouldn't be too hard to start working on an initial wordpress config if we want to do this. @tommcfarlin, @ntwb?

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 21, 2015

Some rules to start: can do a another PR later

Wordpress JSCS
base styles jquery preset
single quotes "validateQuoteMarks": "'"
100 char limit is not strictly enforced "maximumLineLength": null?
Any ! negation operator should have a following space requireSpaceAfterPrefixUnaryOperators: ["!"]
Unary operators have no space around them (except !) "disallowSpaceAfterPrefixUnaryOperators": true, "disallowSpaceBeforePostfixUnaryOperators": true

update jquery preset?

jQuery JSCS
indentation with tabs "validateIndentation": "\t"
if/else/for/while/try blocks should always use braces, and always go on multiple lines "requireBlocksOnNewline": true
Any , and ; must not have preceding space. maybe validateParameterSeparator? Not sure if we have the semicolon rule
@paulschreiber

This comment has been minimized.

Copy link
Author

commented Feb 22, 2015

@hzoo Thanks! I'm happy to help with this — let me know if I should start a new branch or if you have one already.

@zxqfox zxqfox added the preset label Feb 22, 2015

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 23, 2015

Yeah @paulschreiber I'l begin a PR soon so we can start figuring out more rules.

@hzoo hzoo referenced this issue Feb 23, 2015

Closed

Preset: wordpress #1105

@markelog

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

VIP?

@paulschreiber

This comment has been minimized.

Copy link
Author

commented Feb 24, 2015

@markelog WordPress VIP is the paid-hosting version of WordPress. For PHP, the WordPress VIP coding standards add some additional rules to the WordPress coding standards.
https://vip.wordpress.com/documentation/code-review-what-we-look-for/
https://vip.wordpress.com/documentation/code-and-theme-review-process/
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

For JavaScript, I don't think there are additional rules; we can refer to this as the "WordPress" preset.

@westonruter and/or @joshbetz can confirm if this is the case.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2015

It would be helpful to have a WordPress VIP preset. Their style rules — based on jQuery — are here:
https://make.wordpress.org/core/handbook/coding-standards/javascript/

Note that these aren't WordPress.com VIP standards. They are WordPress Core standards. So the JSCS naming standard should reflect that. For PHP_CodeSniffer we have a “WordPress” superset standard library with all of the sniffs, and then we have subset standards for “WordPress-Core”, “WordPress-VIP”, and “WordPress-Extra”.

Just wanted to note as well that PHP_CodeSniffer supports tokenizing and applying sniffs to JS as well as PHP. Some of the sniffs in the WordPress-Coding-Standards project apply to JS files as well, though PHP has been the exclusive focus for that project thus far.

See also: WordPress/WordPress-Coding-Standards#39

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

@westonruter Should this preset be wordpress-core, wordpress, or something else?

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2015

Depends on how many rules you come up with. If you're specifically targeting the standards in the Core handbook, then wordpress-core seems right.

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

Right now I've only started with https://make.wordpress.org/core/handbook/coding-standards/javascript/ since that was the original link that was given. I think we're open to whatever is needed - although I guess wordpress-core since it applies to more people?

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2015

👍

@mrjoelkemp

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

For the record, if this preset will only be used within wordpress core, then the jscsrc (i.e., wordpress preset) should live in that project – not maintained by jscs core.

Similar to grunt, if this preset will be used to enforce the wordpress style across all wordpress plugins, then the preset will be widely used and is a great candidate for inclusion in jscs core.

@paulschreiber

This comment has been minimized.

Copy link
Author

commented Feb 24, 2015

@mrjoelkemp The preset would be useful to all WordPress theme and plugin developers, not just folks who work on WordPress core, and would be a great addition to jscs core.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2015

👍 The WordPress Core coding standards should be used by themes and plugins as well, so it wouldn't be limited to the Core project itself: so yes should be used across all WordPress projects.

BTW, there is a .jshintrc in Core: https://core.trac.wordpress.org/browser/trunk/.jshintrc

@mrjoelkemp

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

Sweet. +1 to this

@hzoo

This comment has been minimized.

Copy link
Member

commented Feb 24, 2015

Great! I started a PR: #1105.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Mar 31, 2015

Opened Trac ticket to get this added to WordPress Core: https://core.trac.wordpress.org/ticket/31823

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Mar 31, 2015

Also opened PR to add it to VIP Quickstart, as referenced above: Automattic/vip-quickstart#414

@hzoo

This comment has been minimized.

Copy link
Member

commented Apr 1, 2015

If you guys do add it to wordpress core (or even just run it on the codebase) - there will probably be a lot of changes needed to the preset (added and removed). Like #1187.

So you can create an issue/PR about it so we can get it in.

And if there's differences in rules because of jquery changes we could move the original jquery rules into wordpress so it doesn't depend on another preset (if needed).

Maybe it would be interesting to not have to depend on jscs itself for the preset definitions (but that's probably a different thing altogether and maybe already discussed?).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.