Linting
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
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.