Package Exports
- canonical
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (canonical) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Canonical
Badge
Use this in one of your projects? Include one of these badges in your README to let people know that your code is using the Canonical style.
[](https://github.com/gajus/canonical)
Usage
Command Line
The easiest way to use Canonical to check your code style is to install it as a Node command line program.
npm install canonical -g
After that, you can run Canonical on any JavaScript or CSS file:
# Lint all JavaScript in ./src/ directory.
canonical ./src/**/*.js
# Lint all CSS in ./src/ directory.
canonical ./src/**/*.css
# Lint all JavaScript and CSS in ./src/ directory.
canonical ./src/**/*.js ./src/**/*.css
Node.js API
Gulp
Using Canonical does not require a Gulp plugin. Canonical program interface gives access to all features. Use Canonical API in combination with a glob pattern matcher (e.g. globby) to lint multiple files, e.g.
import gulp from 'gulp';
import glob from 'globby';
import {
lintText,
lintFiles,
getFormatter
} from 'canonical/es';
gulp.task('lint-javascript', () => {
return glob(['./**/*.js'])
.then((paths) => {
let formatter,
report;
formatter = getFormatter();
report = lintFiles(paths);
if (report.errorCount || report.warningCount) {
console.log(formatter(report.results));
}
});
});
This example is written using ES6 syntax. If you want your gulpfile.js
to use ES6 syntax, you have to execute it using Babel or an equivalent code-to-code compiler (ES6 to ES6), e.g.
babel-node ./node_modules/.bin/gulp lint-javascript