Code Monkey home page Code Monkey logo

wordpress-coding-standards's Introduction

Latest Stable Version Release Date of the Latest Version 🚧 Latest Unstable Version

Basic QA checks Unit Tests codecov.io

Minimum PHP Version Tested on PHP 5.4 to 8.3

License: MIT Total Downloads

WordPress Coding Standards for PHP_CodeSniffer


Introduction

This project is a collection of PHP_CodeSniffer rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official WordPress Coding Standards.

This project needs funding. Find out how you can help.

Minimum Requirements

The WordPress Coding Standards package requires:

For the best results, it is recommended to also ensure the following additional PHP extensions are enabled:

Installation

As of WordPressCS 3.0.0, installation via Composer using the below instructions is the only supported type of installation.

Composer will automatically install the project dependencies and register the rulesets from WordPressCS and other external standards with PHP_CodeSniffer using the Composer PHPCS plugin.

If you are upgrading from an older WordPressCS version to version 3.0.0, please read the Upgrade guide for ruleset maintainers and end-users first!

Composer Project-based Installation

Run the following from the root of your project:

composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev wp-coding-standards/wpcs:"^3.0"

Composer Global Installation

Alternatively, you may want to install this standard globally:

composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require --dev wp-coding-standards/wpcs:"^3.0"

Updating your WordPressCS install to a newer version

If you installed WordPressCS using either of the above commands, you can upgrade to a newer version as follows:

# Project local install
composer update wp-coding-standards/wpcs --with-dependencies

# Global install
composer global update wp-coding-standards/wpcs --with-dependencies

Using your WordPressCS install

Once you have installed WordPressCS using either of the above commands, use it as follows:

# Project local install
vendor/bin/phpcs -ps . --standard=WordPress

# Global install
%USER_DIRECTORY%/Composer/vendor/bin/phpcs -ps . --standard=WordPress

Pro-tip: For the convenience of using phpcs as a global command, use the Global install method and add the path to the %USER_DIRECTORY%/Composer/vendor/bin directory to the PATH environment variable for your operating system.

Rulesets

Standards subsets

The project encompasses a super-set of the sniffs that the WordPress community may need. If you use the WordPress standard you will get all the checks.

You can use the following as standard names when invoking phpcs to select sniffs, fitting your needs:

  • WordPress - complete set with all of the sniffs in the project

Using a custom ruleset

If you need to further customize the selection of sniffs for your project - you can create a custom ruleset file.

When you name this file either .phpcs.xml, phpcs.xml, .phpcs.xml.dist or phpcs.xml.dist, PHP_CodeSniffer will automatically locate it as long as it is placed in the directory from which you run the CodeSniffer or in a directory above it. If you follow these naming conventions you don't have to supply a --standard CLI argument.

For more info, read about using a default configuration file. See also the provided WordPressCS phpcs.xml.dist.sample file and the fully annotated example ruleset in the PHP_CodeSniffer documentation.

Customizing sniff behaviour

The WordPress Coding Standard contains a number of sniffs which are configurable. This means that you can turn parts of the sniff on or off, or change the behaviour by setting a property for the sniff in your custom [.]phpcs.xml[.dist] file.

You can find a complete list of all the properties you can change for the WordPressCS sniffs in the wiki.

WordPressCS also uses sniffs from PHPCSExtra and from PHP_CodeSniffer itself. The README for PHPCSExtra contains information on the properties which can be set for the sniff from PHPCSExtra. Information on custom properties which can be set for sniffs from PHP_CodeSniffer can be found in the PHP_CodeSniffer wiki.

Recommended additional rulesets

PHPCompatibility

The PHPCompatibility ruleset and its subset PHPCompatibilityWP come highly recommended. The PHPCompatibility sniffs are designed to analyse your code for cross-version PHP compatibility.

The PHPCompatibilityWP ruleset is based on PHPCompatibility, but specifically crafted to prevent false positives for projects which expect to run within the context of WordPress, i.e. core, plugins and themes.

Install either as a separate ruleset and run it separately against your code or add it to your custom ruleset, like so:

<config name="testVersion" value="7.0-"/>
<rule ref="PHPCompatibilityWP">
    <include-pattern>*\.php$</include-pattern>
</rule>

Whichever way you run it, do make sure you set the testVersion to run the sniffs against. The testVersion determines for which PHP versions you will receive compatibility information. The recommended setting for this at this moment is 7.0- to support the same PHP versions as WordPress Core supports.

For more information about setting the testVersion, see:

VariableAnalysis

For some additional checks around (undefined/unused) variables, the VariableAnalysis standard is a handy addition.

VIP Coding Standards

For those projects which deploy to the WordPress VIP platform, it is recommended to also use the official WordPress VIP coding standards ruleset.

How to use

Command line

Run the phpcs command line tool on a given file or directory, for example:

vendor/bin/phpcs --standard=WordPress wp-load.php

Will result in following output:

--------------------------------------------------------------------------------
FOUND 6 ERRORS AND 4 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------
  36 | WARNING | error_reporting() can lead to full path disclosure.
  36 | WARNING | error_reporting() found. Changing configuration values at
     |         | runtime is strongly discouraged.
  52 | WARNING | Silencing errors is strongly discouraged. Use proper error
     |         | checking instead. Found: @file_exists( dirname(...
  52 | WARNING | Silencing errors is strongly discouraged. Use proper error
     |         | checking instead. Found: @file_exists( dirname(...
  75 | ERROR   | Overriding WordPress globals is prohibited. Found assignment
     |         | to $path
  78 | ERROR   | Detected usage of a possibly undefined superglobal array
     |         | index: $_SERVER['REQUEST_URI']. Use isset() or empty() to
     |         | check the index exists before using it
  78 | ERROR   | $_SERVER['REQUEST_URI'] not unslashed before sanitization. Use
     |         | wp_unslash() or similar
  78 | ERROR   | Detected usage of a non-sanitized input variable:
     |         | $_SERVER['REQUEST_URI']
 104 | ERROR   | All output should be run through an escaping function (see the
     |         | Security sections in the WordPress Developer Handbooks), found
     |         | '$die'.
 104 | ERROR   | All output should be run through an escaping function (see the
     |         | Security sections in the WordPress Developer Handbooks), found
     |         | '__'.
--------------------------------------------------------------------------------

Using PHPCS and WordPressCS from within your IDE

The wiki contains links to various in- and external tutorials about setting up WordPressCS to work in your IDE.

Running your code through WordPressCS automatically using Continuous Integration tools

Fixing errors or ignoring them

You can find information on how to deal with some of the more frequent issues in the wiki.

Tools shipped with WordPressCS

Since version 1.2.0, WordPressCS has a special sniff category Utils.

This sniff category contains some tools which, generally speaking, will only be needed to be run once over a codebase and for which the fixers can be considered risky, i.e. very careful review by a developer is needed before accepting the fixes made by these sniffs.

The sniffs in this category are disabled by default and can only be activated by adding some properties for each sniff via a custom ruleset.

At this moment, WordPressCS offer the following tools:

  • WordPress.Utils.I18nTextDomainFixer - This sniff can replace the text domain used in a code-base. The sniff will fix the text domains in both I18n function calls as well as in a plugin/theme header. Passing the following properties will activate the sniff:
    • old_text_domain: an array with one or more (old) text domain names which need to be replaced;
    • new_text_domain: the correct (new) text domain as a string.

Contributing

See CONTRIBUTING, including information about unit testing the standard.

Funding

If you want to sponsor the work on WordPressCS, you can do so by donating to the PHP_CodeSniffer Open Collective.

License

See LICENSE (MIT).

wordpress-coding-standards's People

Contributors

anomiex avatar barryceelen avatar c3mdigital avatar ckanitz avatar dependabot[bot] avatar dingo-d avatar dixitadusara avatar fulldecent avatar garyjones avatar gedex avatar grappler avatar jdgrimes avatar johnbillion avatar jrfnl avatar luc45 avatar mattyrob avatar mrchrisadams avatar nielsdeblaauw avatar ntwb avatar nyordanov avatar ockham avatar paulschreiber avatar rarst avatar richardkorthuis avatar sandeshjangam avatar shadyvb avatar tfrommen avatar tomjn avatar wesm87 avatar westonruter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-coding-standards's Issues

Create sniff to flag missing PHPDoc comments

All functions should include a PHPDoc comment block which indicate the parameters and return value, along with a description of what the function does.

Example. Note: curly braces should not be used around type statement eg: @param {array} $some_array These can not be parsed by PHPDocumenter.

//Correct
/**
 * Sets the post thumbnail on the list table
 *
 * @param int $post_id
 * @param string $size, The thumbnail size to use (optional)
 * @return bool|string, post thumbnail if post has thumbnail, false if not
 */
function wpized_list_thumbnail( $post_id, $size='medium' ) {

Reported by @c3mdigital

Require alternative syntax for control structures in templates

It is easy to sneak in logic into templates. I think a handy way to remind yourself not to do this is to always use PHP's alternative syntax for control structures in WP templates: http://www.php.net/manual/en/control-structures.alternative-syntax.php

The use of this syntax lends itself much better to meshing with markup since the tags are much more apparent, and it makes it much easier to indent with markup. Lastly, it is much more readable to see <?php endif; ?> then just <?php } ?>

} else { //Are we allowed to comment here? If not, message is wrong

Reported by @mwic: I make frequent use of comments on else control structures , so that I don't have to scroll around to see what condition is being else'd. e.g.
if ( $parrotIsAlive ) {
[snip]
} else { //parrot has ceased to be
[snip]
}

With your standard I get a misleading message on this attempt.
"Blank line found at start of control structure"
Whether or not the comment is allowed, the message needs to be fixed

Full writeup:
http://mwic.org/wp/index.php/blank-line-found-at-start-of-control-structure-when-there-isnt-a-blank-line-there

https://gist.github.com/mwic/5248309

Integrate checks for JavaScript Coding Standards

On 21 March 2013, Tom McFarlin posted that he contributed the first ever WordPress JavaScript Coding Standards:

Anyway, one of the things about the WordPress Coding Standards that’s always seemed incomplete to me is how little it focused on JavaScript. It provides guides for PHP, for HTML, and it even has a stub for CSS, but there’s nothing in the Codex about JavaScript.

For the past few months, I’ve been working on exactly that. Today, I contributed to the WordPress Coding Standards by introducing the WordPress JavaScript Coding Standards.

The JavaScript Coding Standards have been moved over to the Core Contributor Handbook: http://make.wordpress.org/core/handbook/coding-standards/javascript/

We should look at creating sniffs specifically for enforcing the JavaScript rules.

Update or delegate installation instructions

The current installation instructions depend on pear and git. Suggestion to use pear is taken by some people a little worse than suggestion to stab themselves in the face. Git is better, but might not be immediately available in beginner circles.

PHP CS currently has three ways to install documented: pear, composer and git (however only pear seems to produce correct bat files on Windows :(. It would make sense to extend installation instructions here to mention those or simply drop them completely and link off to PHPCS original instructions.

As possibility we could potentially put together Composer package that will bundle PHPCS and WP standard together for one-command (or one phar file) install.

Thoughts?

Create sniff to make sure that wp_reset_postdata() is called after sub-loop

When creating new WP_Query instances and looping over them, it is important that the global post variables are reset to be reflect $wp_the_query. A sniff can check for instantiation of WP_Query followed by use of have_posts() and the_post() and if after this loop there does not exist a wp_reset_postdata(), there should be a warning flagged.

Discouraged functions sniff

print_r() and var_dump() forbidden, really? :)

I understand it might make sense to sniff for them in production code, but just gets in the way in development and is for sure extra territory.

Also while sniff is called "discouraged" functions it seems to output messages with "forbidden" version of wording.

Create sniff to enforce registration of scripts and stylesheets

Scripts and stylesheets should not be hard-coded in templates. On the contrary, they should be registered using wp_register_script() and wp_register_style() during the wp_enqueue_scripts action. If a stylesheet <link> is hard-coded in the <head> then they are doing it wrong, or if a <script src="..."> appears in the footer, they are doing it wrong.

Provide facility to ignore reporting on lines already committed

In order to be really useful, it should be possible to only report errors and warnings on lines that have been touched, and ignore the lines that have already been there. This is key for use with Core development.

A wrapper script could be provided which invokes phpcs, but which filters out lines from the report that do not correspond with uncommitted changes.

ControlStructureSpacing

Is there a way to ignore parts of Sniffs? For example, I would like to ignore this rule: 'Blank line found at start of control structure' found here:

$firstContent = $phpcsFile->findNext(T_WHITESPACE, ($scopeOpener + 1), null, true);
if ($tokens[$firstContent]['line'] !== ($tokens[$scopeOpener]['line'] + 1) && $tokens[$firstContent]['code'] != T_CLOSE_TAG) {
    $error = 'Blank line found at start of control structure';
    $phpcsFile->addError($error, $scopeOpener);
}

$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($scopeCloser - 1), null, true);
if ($tokens[$lastContent]['line'] !== ($tokens[$scopeCloser]['line'] - 1)) {
    $errorToken = $scopeCloser;
    for ($i = ($scopeCloser - 1); $i > $lastContent; $i--) {
        if ($tokens[$i]['line'] < $tokens[$scopeCloser]['line'] && $tokens[$firstContent]['code'] != T_OPEN_TAG) {

            $error = 'Blank line found at end of control structure';
            $phpcsFile->addError($error, $i);
            break;
        }
    }

}

Trailing comma on array declaration

Originally reported at http://pear.php.net/bugs/bug.php?id=19162 but as https://github.com/pear/PHP_CodeSniffer/tree/master/CodeSniffer/Standards/PEAR/Sniffs doesn't appear to have a Arrays directory (as I assumed the WP were adapted from the PEAR CS) then it's worth reporting here too.

Description:

Running PHP_CodeSniffer via a phing build on Jenkins, I get that one of the arrays has no trailing comma, yet I believe it has.

It's only a single item in the array, and the value of it is multiple nested function calls which itself includes an array.

I've got a similar bit of code lower down in my file which also produces the same error.

Test script:

$actions = array(
    'install' => sprintf( // Line 1179
        '<a href="%1$s" title="Install %2$s">Install</a>',
        wp_nonce_url(
            add_query_arg(
                array(
                    'page'          => TGM_Plugin_Activation::$instance->menu,
                    'plugin'        => $item['slug'],
                    'plugin_name'   => $item['sanitized_plugin'],
                    'plugin_source' => $item['url'],
                    'tgmpa-install' => 'install-plugin',
                ),
                admin_url( TGM_Plugin_Activation::$instance->parent_url_slug )
            ),
            'tgmpa-install'
        ),
        $item['sanitized_plugin']
    ), // <-- This comma not seen?
);

Expected result:

I'd expect no array trailing comma warning to appear.

Actual result:

class-tgm-plugin-activation.php:1179, ArrayDeclaration, Priority: High
Each line in an array declaration must end in a comma

Multi-line function definition not indented correctly

Hello,

Being relatively new with this I hope it would be OK to ask in perhaps not that many technical terms.

I was wondering on how to write this snippet best:

add_action( 'init', 'create_secondary_taxonomies' );
function create_secondary_taxonomies() {
  $labels = array(
    'name' => _x( 'Mogelijkheden', 'taxonomy general name' ),
    'singular_name' => _x( 'Mogelijkheid', 'taxonomy singular name' ),
  );
  register_taxonomy(
    'mogelijkheid',
    array( 'product' ),
    array(
      'labels' => $labels,
      'hierarchical' => true,
      'query_var' => true,
      'rewrite' => array(
        'hierarchical' => true,
        'slug' => 'mogelijkheid',
        'with_front' => false,
      ),
      'public' => true,
      'show_ui' => true,
    )
  );
}

as I'm currently receiving this error:

FOUND 3 ERROR(S) AFFECTING 3 LINE(S)
--------------------------------------------------------------------------------
  9 | ERROR | Multi-line function definition not indented correctly; expected 6
    |       | spaces but found 4 (WordPress.Functions.FunctionCallSignature)
 10 | ERROR | Multi-line function definition not indented correctly; expected 6
    |       | spaces but found 4 (WordPress.Functions.FunctionCallSignature)
 11 | ERROR | Multi-line function definition not indented correctly; expected 6
    |       | spaces but found 4 (WordPress.Functions.FunctionCallSignature)
--------------------------------------------------------------------------------

I can understand why 4 spaces, but I'm somewhat lost on why 6.

Integrate Sniffs with WP-CLI

We could introduce a new WP-CLI subcommand called lint or phpcs which would apply the sniffs in this project to the WordPress install in the current scope.

I'm not sure of the best route to go as for integrating the sniffs into WP-CLI. Perhaps it would mean forking WP-CLI https://github.com/wp-cli/wp-cli and then adding this repo as a submodule dependency.

Extra characters in output of phpcs with WordPress standard

I have downloaded and installed the latest version of phpcs and these WordPress standards. I am running this with Netbeans and XAMPP on a Windows 7 machine. In Netbeans, phpcs works fine with the PEAR standard, but with the WordPress standard it gives this error: [Fatal Error] :1:1: Content is not allowed in prolog.

I ran phpcs.bat from the Windows command line, and the WordPress standard works fine, except that I see 2-3 bytes of garbage characters at the very beginning of the report. Those bytes are not there with the PEAR standard. So I suspect that this is the problem. A few bytes of something are getting output before the XML

Flag direct database queries

Code should not be directly accessing the CRUD methods of $wpdb since there should be WordPress API functions already available to do almost everything normally done.

We could allow for a PHP comment to be added which would direct PHPCS to not flag usage of $wpdb as an error. This is what was done with the EscapeOutputSniff and // xss ok.

In terms of the caching requirement, after an instance of a CRUD method of $wpdb is used, the sniff could then walk over the remainder of the function to check if wp_cache_set is used, and if wp_cache_get appears before. If not, then this would be a caching warning.

  • Flag any use of $wpdb methods
  • Add facility to whitelist usages
  • Check for presence of wp_cache_set and wp_cache_get in the scope of any function using $wpdb

Direct Database Queries #

Thanks to WordPress’ extensive API, you should almost never need to query database tables directly. Using WordPress APIs rather than rolling your own functions saves you time and assures compatibility with past and future versions of WordPress and PHP. It also makes code reviews go more smoothly because we know we can trust the APIs. More information.

Additionally, direct database queries bypass our internal caching. If absolutely necessary, you should evaluate the potential performance of these queries and add caching if needed.

XSS Sniff missing wp sanitizing functions

I needed to print output using wp's wp_kses_post but I was getting an error:

Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'wp_kses_post'

Seems the wp_kses_post function was missing from the $sanitizing_functions array

The following are also defined as sanitizing functions in wordpress codex: data validation:

  • wp_kses_post
  • wp_kses_data
  • wp_kses_allowed_html
  • esc_sql
  • like_escape
  • validate_file
  • wp_redirect
  • wp_safe_redirect
  • sanitize_title
  • sanitize_user
  • balanceTags
  • sanitize_html_class
  • is_email

not sure if this is a duplicate of:
#33

Also, not sure of the contributor rules but need this for work so going to fork and create a feature branch.

typo on README.md

Hi!

Theres is a typo on the README.md file.

Where it says:

git clone git://github.com/mrchrisadams/Wordpress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress

It should read:

git clone git://github.com/mrchrisadams/WordPress-Coding-Standards.git $(pear config-get php_dir)/PHP/CodeSniffer/Standards/WordPress

(note the uppercase P on WordPress-Coding-Standards.git)

echo $foo; Not Valid

The following does not validate:

$foo = 'abc';
echo $foo;

I have to use this workaround:

$foo = 'abc';
echo '' . $foo;

Is this by design?

On a side note, this also does not validate, which is the translation gettext function:

$foo = 'abc';
echo _($foo);

Fix sniff which requires each line of multi-line arrays to end in commas

It doesn't work so well if you have comments or function calls appearing in the array.

<?php
$foo = array(
    'bar' => array_merge(
        array(
            'x' => 1,
        ),
        array(
            'y' => 2,
        )
    ),
    'baz' => function () {
        echo 'Jello World';
    },
);
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
  3 | ERROR | Each line in an array declaration must end in a comma
 11 | ERROR | Each line in an array declaration must end in a comma
--------------------------------------------------------------------------------

Add ruleset XML files to categorize and subset sniffs

A lot of the sniffs are opinionated and may not be reflective of an actual problem. We should have a ruleset XML file that just contains the core sniffs for checking code formatting, and then another ruleset XML that has the extra sniffs (e.g. those labeled with extra in GitHub), perhaps including the other ruleset XML as a base or copying it somehow.

Port over checks from VIP Scanner into sniffs

Automattic has a VIP Scanner tool which would greatly benefit from integrating PHP_CodeSniffer. From looking at the tool, the checks are implemented with regular expressions and so they'll be less powerful than PHPCS's sniffs which operate on tokenized streams.

The checks in the VIP Scanner should be ported over to PHPCS sniffs, then a fine-tuned ruleset (to opt-in/opt-out of the relevant rules) could be employed by the VIP Scanner. In effect, the scanner would become just be a wrapper for PHPCS.

Multiline function call check differs from common practice

This code:

$args = wp_parse_args( $args, array(
    '1' => 1,
    '2' => 2,
) );

produces paired set of warnings about parentheses around arguments of multi-line function call needing to be respectively last and first on their lines.

While I have no issue with such rule, it is not in official spec and existing core code much favors more compact style for such call, as in example snippet.

Check for proper usage of translation functions

I had read that variables were discouraged from being used in the i18n functions. I assumed this was just to discourage them from being changed. Well, it's actually because some automated i18n tools will tokenize the PHP files to extract the textdomain from PHP without actually evaluating the file. See @markjaquith's blog post Translating WordPress Plugins and Themes: Don’t Get Clever.

So a sniff should be written which makes sure that translation functions have a text domain which is a literal string. The sniff should also ensure that variables are not being used for the text to be translated, or inside of the text to be translated.

No blank spaces at the end of lines

It would be good to revise that there are no blank spaces at the end of lines:+1:.

This is a nuisance when working in different operating system.

Make the Escaped Output sniff smarter

The sniff needs more logic to determine safe output

echo 'Some Raw String';  //Causes no escaping function warning
_e( $some_nasty_var );  //No warning
echo apply_filters( 'the_content', $post->post_content );  //Causing no escaping function warning

Reported by @c3mdigital

No blank line at start of control structure is not explicit in official spec

Such code:

if ( true ) {

    // code
}

Triggers warning about blank line at start of control structure. While official spec doesn't have blank lines in examples:

if ( condition ) {
    action1();
    action2();
} elseif ( condition2 && condition3 ) {
    action3();
    action4();
} else {
    defaultaction();
}

...it doesn't forbid them explicitly or even comment on them. This is hugely annoying for code bases where such blank line is common.

I would suggest to either seek clarification in official spec or dump the rule from the main standard.

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.