Linting: Difference between revisions
From MoodleDocs
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
== PHP (PHP_CodeSniffer) == | == PHP (PHP_CodeSniffer) == | ||
PHP code | PHP code is linted by [https://github.com/squizlabs/PHP_CodeSniffer PHP_CodeSniffer]. | ||
=== Rules === | === Rules === | ||
Line 12: | Line 12: | ||
Javascript code is linted with [http://eslint.org eslint]. | Javascript code is linted with [http://eslint.org eslint]. | ||
=== grunt js ==== | |||
Linting is enforced in the Javascript build process for both AMD and YUI modules. | |||
=== Rules === | === Rules === | ||
ESlint rules are defined within | ESlint rules enabled for Moodle are defined within [https://github.com/moodle/moodle/blob/master/.eslintrc .eslintrc] and the eslint website provides [http://eslint.org/docs/rules/ 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 === | === Ignores === | ||
== CSS/SCSS/Less (stylelint) == | |||
CSS code is linted by [http://stylelint.io stylelint]. | |||
=== grunt css ==== | |||
=== Rules === | === Rules === | ||
Line 29: | Line 39: | ||
=== Ignores === | === Ignores === | ||
= | = Linting in your editor = | ||
== Atom == | == Atom == | ||
== Eclipse == | |||
== PHPStorm == | |||
== Vim == | |||
== Visual Studio Code == | == Visual Studio Code == | ||
Revision as of 15:25, 28 November 2016
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.