stevegrunwell / wp-enforcer

Git hooks to encourage well-written WordPress.
https://stevegrunwell.com/blog/wp-enforcer/
MIT License
111 stars 14 forks source link

Add support for JavaScript coding standards #23

Open stevegrunwell opened 8 years ago

stevegrunwell commented 8 years ago

WordPress has an official .jshintrc file and PHP_CodeSniffer can be configured to run it automatically, we just need to put those pieces together so JavaScript can automatically be linted/hinted/otherwise checked.

dana-ross commented 8 years ago

One of my projects uses JSCS. It would be great to be able to choose JSHint or JSCS.

ghost commented 7 years ago

One of my projects uses JSCS. It would be great to be able to choose JSHint or JSCS.

No one should be using JSCS or JSHint these days. Those tools are dead, and have been replaced by ESLint and JavaScript Standard Style.

The Linux philosophy is that a tool should be good at one thing and one thing only. Adding JS linting to enforcer will only conflate the usefulness of other existing tools which already do this handily.

stevegrunwell commented 7 years ago

No one should be using JSCS or JSHint these days. Those tools are dead, and have been replaced by ESLint and JavaScript Standard Style.

While it's great to be able to use ESLint or JavaScript Standard Style on new builds, that's not always an option (especially with existing projects and/or in agencies). This is compounded by the fact that WordPress has its own JavaScript coding standards and, as WP Enforcer is meant to be a tool to aid in writing to the WordPress coding standards, the checks that it uses must adhere to what's set forth by the WordPress project.

@jhabdas raises a good point about the conflation of responsibilities, but I'd counter with the thought that WP Enforcer's goal is to automatically install git hooks to prevent non-standards-compliant code from being committed to a WordPress project; PHP was a logical starting point, but both JavaScript and HTML feel very much in the scope of this project.

ghost commented 7 years ago

Thankfully WordPress has core issues out to move to ESlint. They wouldn't bite on JavaScript Stamdard when I proposed it on Trac, citing technical debt and a desire to make JS look like their PHP as the rationale.