Research: Useful Information that can be extracted from Gulpfile.js
Language : Javascript
Parsing Method : PyJSParser, generates a parsed dictionary of a JS file
Relevant Issues: Not any existing issue regarding this, to be created once the ideas are agreed upon.
Example usage: https://raw.githubusercontent.com/clef/clef-wordpress/master/gulpfile.js
As gulp is also a web-specific task runner like grunt that is primarily used for specifying tasks for building a web-based project. Most of the times, these task-runners include lint tasks that can be utilized by coala by following ways.
Information of interest to coala
Structure of Gulpfile.js
Typical example of usage of gulp-csslint
var csslint = require('gulp-csslint');
gulp.task('css', function() {
gulp.src('client/css/*.css')
.pipe(csslint({
'shorthand': false
}))
.pipe(csslint.formatter());
});
Generalizing from common usage
var some_linter = require('gulp-somelinter');
gulp.task('lint', function() {
gulp.src('target files')
.pipe(some_linter({
// configuration settings specific to the linter
}))
});
A simple approach for extracting info may be
- Extract the tool name from the gulp plugin's name. Conventional format is
gulp-toolname
- If the toolanme corresponds to a linter wrapped by coala, then record the variable where it is defined using the syntax
var some_linter = require('gulp-somelinter');
- Iterate tasks one by one
- Check if it's a lint subtask or it's a task containing pipe of
some_linter
recorded in the previous step. - Extract the settings from the tasks of interest discovered.
Info of interest
- The
gulp.src
argument will give Target files to include, - The call to
some_linter
may contain configuration object as the argument and hence some bear-specific setting values of interest.
.pipe(lintername(config of interest))
Similar to Gruntfile.js
, following tasks(linters) and corresponding bears can be detected from Gulpfile.js
coffeelint : CoffeeLintBear
tslint : TSLintBear
typescript : TSLintBear
autoprefixer : CSSAutoPrefixBear
stylelint : StyleLintBear
babel-eslint : ESLintBear
csslint : CSSLintBear
dockerfile_lint : DockerfileLintBear
complexity-report : JSComplexityBear
remark-cli : MarkdownBear
bootlint : BootLintBear
alex : AlexBear
ramllint : RAMLLintBear
jshint : JSHintBear
eslint : ESLintBear
postcss-cli : CSSAutoPrefixBear
remark-lint : MarkdownBear
eslint-plugin-import : ESLintBear
happiness : HappinessLintBear
write-good : WriteGoodLintBear
Sub-issue of https://gitlab.com/coala/GSoC-2017/issues/21