Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Linting

From MoodleDocs
Revision as of 15:25, 28 November 2016 by Dan Poltawski (talk | contribs)

In Moodle development code linters are used to help ensure consistent coding conventions and help prevent common errors in code.

Linters

PHP (PHP_CodeSniffer)

PHP code is linted by PHP_CodeSniffer.

Rules

The rules defined as part of the Code-checker plugin.

Javascript (ESLint)

Javascript code is linted with eslint.

grunt js =

Linting is enforced in the Javascript build process for both AMD and YUI modules.

Rules

ESlint rules enabled for Moodle are defined within .eslintrc and the eslint website provides good documentation on each rules' purpose and examples of correct and incorrect code for each rule.

Auto fixing

Many eslint rules come with auto fixes

Ignores

CSS/SCSS/Less (stylelint)

CSS code is linted by stylelint.

grunt css =

Rules

Ignores

Linting in your editor

Atom

Eclipse

PHPStorm

Vim

Visual Studio Code