├── .gitignore ├── test ├── .gitignore ├── gulp_tsd.json ├── gulp_tsd_latest.json ├── tsd.json ├── tsd_latest.json ├── tsd_from_options.json ├── tsd_from_options_without_src.json └── gulpfile.js ├── gulp_tsd.json ├── .travis.yml ├── gulpfile.js ├── tsd.json ├── Changes ├── package.json ├── LICENSE ├── lib └── tsd.js ├── index.js ├── README.md └── .jshintrc /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | typings/ 3 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | typings/ 2 | typings_*/ 3 | -------------------------------------------------------------------------------- /gulp_tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "reinstall", 3 | "latest": true, 4 | "config": "./tsd.json", 5 | "opts": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.11" 4 | - "0.10" 5 | script: 6 | - npm test 7 | - ./node_modules/.bin/gulp lint 8 | 9 | -------------------------------------------------------------------------------- /test/gulp_tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "reinstall", 3 | "latest": false, 4 | "config": "./tsd.json", 5 | "opts": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/gulp_tsd_latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": "reinstall", 3 | "latest": true, 4 | "config": "./tsd_latest.json", 5 | "opts": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | tsd = require('./index.js'), 3 | jshint = require('gulp-jshint'); 4 | 5 | gulp.task('tsd', function () { 6 | return gulp.src('./gulp_tsd.json').pipe(tsd()); 7 | }); 8 | 9 | gulp.task('lint', function () { 10 | return gulp.src(['index.js', 'lib/**/*.js']) 11 | .pipe(jshint()) 12 | .pipe(jshint.reporter('default')); 13 | }); 14 | -------------------------------------------------------------------------------- /tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings", 6 | "bundle": "typings/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "0de1592ef9e3144b925287ca0494f621e12b01c6" 10 | }, 11 | "goJS/goJS.d.ts": { 12 | "commit": "0de1592ef9e3144b925287ca0494f621e12b01c6" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings", 6 | "bundle": "typings/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "2e2fdad63488930262d09724a3e04d5350b720f1" 10 | }, 11 | "goJS/goJS.d.ts": { 12 | "commit": "70f095961ce0a3bc844af226633f285f4e36799a" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/tsd_latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings_latest", 6 | "bundle": "typings_latest/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" 10 | }, 11 | "goJS/goJS.d.ts": { 12 | "commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/tsd_from_options.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings_from_options", 6 | "bundle": "typings_from_options/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "2e2fdad63488930262d09724a3e04d5350b720f1" 10 | }, 11 | "goJS/goJS.d.ts": { 12 | "commit": "70f095961ce0a3bc844af226633f285f4e36799a" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/tsd_from_options_without_src.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings_from_options_without_src", 6 | "bundle": "typings_from_options_without_src/tsd.d.ts", 7 | "installed": { 8 | "jquery/jquery.d.ts": { 9 | "commit": "2e2fdad63488930262d09724a3e04d5350b720f1" 10 | }, 11 | "goJS/goJS.d.ts": { 12 | "commit": "70f095961ce0a3bc844af226633f285f4e36799a" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Changes: -------------------------------------------------------------------------------- 1 | Revision history for gulp-tsd 2 | 3 | 0.1.1 2016-03-03T12:55:02X 4 | 5 | - Add "rebundle" command which calls API.updateBundle similarly to how 6 | CLI.rebundle works. 7 | 8 | 0.1.0 2016-01-13T13:58:55Z 9 | 10 | - Allow configurable debugging by using `debug` module (@goldcaddy77) 11 | See: https://github.com/moznion/gulp-tsd/pull/14 12 | 13 | 0.0.4 2014-12-02T14:09:01Z 14 | 15 | - Update dependent tsd version (@Nemo157) 16 | See: https://github.com/moznion/gulp-tsd/pull/5 17 | 18 | 0.0.3 2014-08-20T16:01:44Z 19 | 20 | - Fixed path resolving to allow place the config into nested folders instead of root (@ebaranov) 21 | - Allow passing in options instead of file (@Nemo157) 22 | 23 | 0.0.2 2014-05-30T23:54:11Z 24 | 25 | - Fix some typos in doc 26 | 27 | 0.0.1 2014-05-30T23:32:23Z 28 | 29 | - original version 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-tsd", 3 | "author": "moznion ", 4 | "version": "0.1.1", 5 | "description": "Gulp plugin to automate TSD and TypeScript definition related tasks", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "./node_modules/.bin/gulp --gulpfile ./test/gulpfile.js" 9 | }, 10 | "keywords": [ 11 | "gulp", 12 | "tsd" 13 | ], 14 | "dependencies": { 15 | "debug": "^2.2.0", 16 | "gulp-util": "^3.0.7", 17 | "through2": "^2.0.0", 18 | "tsd": "~0.6.5" 19 | }, 20 | "devDependencies": { 21 | "gulp": "~3.9.0", 22 | "gulp-clean": "~0.3.1", 23 | "gulp-run-sequence": "~0.3.2", 24 | "chai": "~3.4.1" 25 | }, 26 | "optionalDependencies": { 27 | "gulp-jshint": "~2.0.0" 28 | }, 29 | "homepage": "https://github.com/moznion/gulp-tsd", 30 | "bugs": "https://github.com/moznion/gulp-tsd/issues", 31 | "repository": { 32 | "type": "git", 33 | "url": "git://github.com/moznion/gulp-tsd.git" 34 | }, 35 | "license": "MIT" 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 by moznion 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /lib/tsd.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | 5 | function getRunner(logger) { 6 | var tsd = require('tsd'); 7 | 8 | function getAPI(setting) { 9 | logger.log('config:', setting.config); 10 | var api = tsd.getAPI(setting.config); 11 | if (setting.cacheDir) { 12 | logger.log('cacheDir:', setting.cacheDir); 13 | api.context.paths.cacheDir = path.resolve(setting.cacheDir); 14 | } 15 | return api; 16 | } 17 | 18 | function reinstall(setting) { 19 | logger.log('execute command: reinstall'); 20 | 21 | var api = getAPI(setting); 22 | return api.readConfig(setting.config, true).then(function () { 23 | var opts = tsd.Options.fromJSON(setting.opts); 24 | var isLatest = setting.latest; 25 | var query; 26 | 27 | opts.saveBundle = true; 28 | opts.overwriteFiles = true; 29 | opts.resolveDependencies = true; 30 | 31 | logger.log('latest:', isLatest); 32 | logger.log('running...'); 33 | if (isLatest) { 34 | opts.saveToConfig = true; 35 | query = new tsd.Query(); 36 | api.context.config.getInstalled().forEach(function (inst) { 37 | var def = tsd.Def.getFrom(inst.path); 38 | query.addNamePattern(def.project + '/' + def.name); 39 | }); 40 | query.versionMatcher = new tsd.VersionMatcher('latest'); 41 | 42 | return api.select(query, opts).then(function (selection) { 43 | return api.install(selection, opts); 44 | }); 45 | } 46 | return api.reinstall(opts); 47 | }); 48 | } 49 | 50 | function rebundle(setting) { 51 | logger.log('execute command: rebundle'); 52 | 53 | var api = getAPI(setting); 54 | return api.readConfig(setting.config, true).then(function () { 55 | logger.log('running...'); 56 | return api.updateBundle(api.context.config.bundle, true); 57 | }); 58 | } 59 | 60 | return { 61 | getAPI: getAPI, 62 | commands: { 63 | reinstall: reinstall, 64 | rebundle: rebundle 65 | } 66 | }; 67 | } 68 | 69 | module.exports = { 70 | getRunner: getRunner 71 | }; 72 | 73 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var tsd = require('./lib/tsd'); 2 | var through = require('through2'); 3 | var gutil = require('gulp-util'); 4 | var path = require('path'); 5 | var debug = require('debug')('gulp-tsd'); 6 | 7 | module.exports = function (options, callback) { 8 | 'use strict'; 9 | 10 | var settings = []; 11 | if (options) { 12 | settings.push(options); 13 | } 14 | 15 | var logger = { 16 | 'log': function () { 17 | var args = Array.prototype.slice.call(arguments), 18 | printfString = Array.apply(null, Array(args.length)).map(function(){return '%o';}).join(' '); 19 | 20 | args.unshift(printfString); 21 | debug.apply(null, args); 22 | } 23 | }; 24 | 25 | var finishedWorkers = 0; 26 | var promised = function (context, promise, callback) { 27 | promise.done(function () { 28 | if (settings.length === ++finishedWorkers) { 29 | logger.log('finish'); 30 | return callback(); 31 | } 32 | }, function (err) { 33 | if (settings.length === ++finishedWorkers) { 34 | context.emit('error', new gutil.PluginError('gulp-tsd', 'Failed command execution: ' + err.stack)); 35 | return callback(); 36 | } 37 | }); 38 | }; 39 | 40 | function transform(file, encode, callback) { 41 | /*jshint validthis:true */ 42 | if (file.isNull()) { 43 | this.push(file); 44 | return callback(); 45 | } 46 | 47 | if (file.isStream()) { 48 | this.emit('error', new gutil.PluginError('gulp-tsd', 'Streaming not supported')); 49 | return callback(); 50 | } 51 | 52 | settings.push(require(path.resolve(file.path))); 53 | 54 | callback(); 55 | } 56 | 57 | function flush(callback) { 58 | /*jshint validthis:true */ 59 | var self = this; 60 | settings.forEach(function (setting) { 61 | var command = setting.command; 62 | var tsdCommand = tsd.getRunner(logger).commands[command]; 63 | if (typeof tsdCommand === 'undefined') { 64 | self.emit( 65 | 'error', 66 | new gutil.PluginError('gulp-tsd', '"' + command + '"' + ' command is not supported') 67 | ); 68 | return callback(); 69 | } 70 | 71 | return promised(self, tsdCommand(setting), callback); 72 | }); 73 | } 74 | 75 | if (callback) { 76 | flush(callback); 77 | } 78 | 79 | return through.obj(transform, flush); 80 | }; 81 | 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gulp-tsd [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] 2 | 3 | Gulp plugin to automate TSD and TypeScript definition related tasks 4 | 5 | ## GETTING START 6 | 7 | ### 1. Install `gulp-tsd` 8 | 9 | npm install --save-dev gulp-tsd 10 | 11 | ### 2. Write `gulpfile.js` 12 | 13 | For example; 14 | 15 | ```javascript 16 | var tsd = require('gulp-tsd'); 17 | 18 | gulp.task('tsd', function () { 19 | return gulp.src('./gulp_tsd.json').pipe(tsd()); 20 | }); 21 | ``` 22 | 23 | or if you want to specify your options inline in your gulpfile 24 | 25 | ```javascript 26 | var tsd = require('gulp-tsd'); 27 | 28 | gulp.task('tsd', function (callback) { 29 | tsd({ 30 | command: 'reinstall', 31 | config: './tsd.json' 32 | }, callback); 33 | }); 34 | ``` 35 | 36 | ### 3. Write `gulp_tsd.json` (see blow) 37 | 38 | ### 4. Write `tsd.json` (see below) 39 | 40 | ### 5. Run! 41 | 42 | ## DESCRIPTION 43 | 44 | ### gulp_tsd.json (convenient name, you can give a name as you like) 45 | 46 | Setting file for this plugin. 47 | Pass this file to entry point of this plugin through `gulp.src`. 48 | 49 | e.g. 50 | 51 | ```json 52 | { 53 | "command": "reinstall", // this plugin supports only "reinstall" 54 | "latest": true, // if this property is true, tsd always fetches HEAD definitions 55 | "config": "./tsd.json", // file path for configuration file (see below) 56 | "opts": { 57 | // options, EXPERIMENTAL 58 | } 59 | } 60 | ``` 61 | 62 | 63 | ### tsd.json (convenient name, you can give a name as you like) 64 | 65 | Configuration file for [tsd](https://github.com/DefinitelyTyped/tsd). 66 | Specify this file by setting json (yes, above one). 67 | 68 | e.g. 69 | 70 | ```json 71 | { 72 | "version": "v4", 73 | "repo": "borisyankov/DefinitelyTyped", 74 | "ref": "master", 75 | "path": "typings", 76 | "bundle": "typings/tsd.d.ts", 77 | "installed": { 78 | "jquery/jquery.d.ts": { 79 | "commit": "0de1592ef9e3144b925287ca0494f621e12b01c6" 80 | } 81 | } 82 | } 83 | ``` 84 | 85 | Please refer to the [tsd.json](https://github.com/DefinitelyTyped/tsd#tsdjson) to get more information. 86 | 87 | ## DEBUGGING 88 | 89 | This library uses the popular [debug](https://github.com/visionmedia/debug) module for debugging. To enable logging, set the `DEBUG` environment variable when running gulp tasks like so: 90 | 91 | ``` 92 | DEBUG=gulp-tsd gulp tsd 93 | ``` 94 | 95 | ## NOTES 96 | 97 | A lot of codes are from [grunt-tsd](https://github.com/DefinitelyTyped/grunt-tsd). Thanks. 98 | 99 | ## SEE ALSO 100 | 101 | - [tsd](https://github.com/DefinitelyTyped/tsd) 102 | - [grunt-tsd](https://github.com/DefinitelyTyped/grunt-tsd) 103 | 104 | ## LICENSE 105 | 106 | MIT 107 | 108 | [npm-url]: https://npmjs.org/package/gulp-tsd 109 | [npm-image]: https://badge.fury.io/js/gulp-tsd.svg 110 | [travis-url]: https://travis-ci.org/moznion/gulp-tsd 111 | [travis-image]: https://travis-ci.org/moznion/gulp-tsd.svg?branch=master 112 | [daviddm-url]: https://david-dm.org/moznion/gulp-tsd 113 | [daviddm-image]: https://david-dm.org/moznion/gulp-tsd.svg 114 | -------------------------------------------------------------------------------- /test/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var gutil = require('gulp-util'); 3 | var clean = require('gulp-clean'); 4 | var fs = require('fs'); 5 | var runSequence = require('gulp-run-sequence'); 6 | 7 | var chai = require('chai'); 8 | chai.should(); 9 | 10 | var tsd = require('../index'); 11 | 12 | gulp.task('clean', function () { 13 | return gulp.src('typings*', { read: false }).pipe(clean()); 14 | }); 15 | 16 | gulp.task('default', function () { 17 | runSequence( 18 | 'clean', 19 | 'reinstall', 20 | 'reinstall-no-src', 21 | 'reinstall-test', 22 | 'rebundle-test' 23 | ); 24 | }); 25 | 26 | gulp.task('reinstall', function () { 27 | return gulp.src('gulp_tsd*.json').pipe(tsd({ 28 | command: 'reinstall', 29 | latest: false, 30 | config: './tsd_from_options.json', 31 | })); 32 | }); 33 | 34 | gulp.task('reinstall-no-src', function (callback) { 35 | tsd({ 36 | command: 'reinstall', 37 | latest: false, 38 | config: './tsd_from_options_without_src.json', 39 | }, callback); 40 | }); 41 | 42 | gulp.task('reinstall-test', function () { 43 | expectInstalledFilesExist('revision specified files are install in successfully', [ 44 | "./typings/jquery/jquery.d.ts", 45 | "./typings/goJS/goJS.d.ts" 46 | ]); 47 | 48 | expectInstalledFilesExist('latest files are install in successfully', [ 49 | "./typings_latest/tsd.d.ts", 50 | "./typings_latest/jquery/jquery.d.ts", 51 | "./typings_latest/goJS/goJS.d.ts" 52 | ]); 53 | 54 | expectDifferencesBetweenBothFiles('latest file and revision specified file are different', [ 55 | ["./typings/jquery/jquery.d.ts", "./typings_latest/jquery/jquery.d.ts"], 56 | ["./typings/goJS/goJS.d.ts", "./typings_latest/goJS/goJS.d.ts"] 57 | ]) 58 | 59 | expectInstalledFilesExist('options specified files are installed successfully', [ 60 | "./typings_from_options/jquery/jquery.d.ts", 61 | "./typings_from_options/goJS/goJS.d.ts" 62 | ]); 63 | 64 | expectInstalledFilesExist('options specified files are installed successfully without src', [ 65 | "./typings_from_options_without_src/jquery/jquery.d.ts", 66 | "./typings_from_options_without_src/goJS/goJS.d.ts" 67 | ]); 68 | }); 69 | 70 | gulp.task('rebundle-test', function (callback) { 71 | tsd({ 72 | command: 'rebundle', 73 | config: './tsd.json', 74 | }, callback); 75 | }); 76 | 77 | function expectDifferencesBetweenBothFiles(description, diffTargets) { 78 | var testNum = 0; 79 | try { 80 | diffTargets.forEach(function (diffTargetFiles) { 81 | var text1 = fs.readFileSync(diffTargetFiles[0], 'utf-8'); 82 | var text2 = fs.readFileSync(diffTargetFiles[1], 'utf-8'); 83 | text1.should.not.be.equals(text2); 84 | testNum++; 85 | }); 86 | } catch (err) { 87 | report('fail', {"description": description, "err": err}); 88 | process.exit(1); 89 | return; 90 | } 91 | 92 | report('pass', {"description": description, "testNum": testNum}); 93 | } 94 | 95 | function expectInstalledFilesExist(description, targetFiles) { 96 | var testNum = 0; 97 | try { 98 | targetFiles.forEach(function (targetFile) { 99 | fs.existsSync(targetFile).should.be.ok; 100 | testNum++; 101 | }); 102 | } catch (err) { 103 | report('fail', {"description": description, "err": err}); 104 | process.exit(1); 105 | } 106 | report('pass', {"description": description, "testNum": testNum}); 107 | } 108 | 109 | function report(type, args) { 110 | if (type === 'pass') { 111 | gutil.log( 112 | gutil.colors.green("\u2668 PASS:"), 113 | args.description, 114 | gutil.colors.magenta('@', args.testNum + ' test(s)') 115 | ); 116 | } 117 | else if (type === 'fail') { 118 | gutil.log( 119 | gutil.colors.red("\u2620 FAIL:"), 120 | gutil.colors.magenta(args.err), 121 | 'in', args.description 122 | ); 123 | } 124 | } 125 | 126 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | // http://www.jshint.com/docs/ 3 | // Based on node-jshint@2.x.x 4 | 5 | // ENFORCING OPTIONS 6 | // These options tell JSHint to be more strict towards your code. Use them if 7 | // you want to allow only a safe subset of JavaScript—very useful when your 8 | // codebase is shared with a big number of developers with different skill 9 | // levels. 10 | 11 | "bitwise": true, //prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others 12 | "camelcase": true, //force all variable names to use either camelCase style or UPPER_CASE with underscores 13 | "curly": true, //requires you to always put curly braces around blocks in loops and conditionals 14 | "eqeqeq": true, //prohibits the use of == and != in favor of === and !== 15 | "es3": false, //tells JSHint that your code needs to adhere to ECMAScript 3 specification 16 | "forin": true, //requires all `for in` loops to filter object's items with `hasOwnProperty()` 17 | "immed": true, //prohibits the use of immediate function invocations without wrapping them in parentheses 18 | "indent": 2, //enforces specific tab width 19 | "latedef": true, //prohibits the use of a variable before it was defined 20 | "newcap": true, //requires you to capitalize names of constructor functions 21 | "noarg": true, //prohibits the use of `arguments.caller` and `arguments.callee` 22 | "noempty": true, //warns when you have an empty block in your code 23 | "nonew": true, //prohibits the use of constructor functions for side-effects 24 | "plusplus": false, //prohibits the use of unary increment and decrement operators 25 | "quotmark": true, //enforces the consistency of quotation marks used throughout your code 26 | "undef": true, //prohibits the use of explicitly undeclared variables 27 | "unused": true, //warns when you define and never use your variables 28 | "strict": true, //requires all functions to run in ECMAScript 5's strict mode 29 | "trailing": true, //makes it an error to leave a trailing whitespace in your code 30 | "maxparams": 4, //set the max number of formal parameters allowed per function 31 | "maxdepth": 3, //control how nested do you want your blocks to be 32 | //"maxstatements": 0, //set the max number of statements allowed per function 33 | //"maxcomplexity": 0, //control cyclomatic complexity throughout your code 34 | "maxlen": 120, //set the maximum length of a line 35 | 36 | // RELAXING OPTIONS 37 | // These options allow you to suppress certain types of warnings. Use them 38 | // only if you are absolutely positive that you know what you are doing. 39 | 40 | "asi": false, //suppresses warnings about missing semicolons 41 | "boss": false, //suppresses warnings about the use of assignments in cases where comparisons are expected 42 | "debug": false, //suppresses warnings about the debugger statements in your code 43 | "eqnull": false, //suppresses warnings about == null comparisons 44 | "esnext": false, //your code uses ES.next specific features such as const 45 | "evil": false, //suppresses warnings about the use of eval 46 | "expr": false, //suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls 47 | "funcscope": false, //suppresses warnings about declaring variables inside of control structures while accessing them later from the outside 48 | "globalstrict": false, //suppresses warnings about the use of global strict mode 49 | "iterator": false, //suppresses warnings about the `__iterator__` property 50 | "lastsemic": false, //suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block 51 | "laxbreak": false, //suppresses most of the warnings about possibly unsafe line breakings in your code 52 | "laxcomma": false, //suppresses warnings about comma-first coding style 53 | "loopfunc": false, //suppresses warnings about functions inside of loops 54 | "moz": false, //tells JSHint that your code uses Mozilla JavaScript extensions 55 | "multistr": false, //suppresses warnings about multi-line strings 56 | "proto": false, //suppresses warnings about the `__proto__` property 57 | "scripturl": false, //suppresses warnings about the use of script-targeted URLs—such as `javascript:...` 58 | "smarttabs": false, //suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only 59 | "shadow": false, //suppresses warnings about variable shadowing 60 | "sub": false, //suppresses warnings about using `[]` notation when it can be expressed in dot notation 61 | "supernew": false, //suppresses warnings about "weird" constructions like `new function () { ... }` and `new Object;` 62 | "validthis": false, //suppresses warnings about possible strict violations when the code is running in strict mode and you use `this` in a non-constructor function 63 | 64 | // ENVIRONMENTS 65 | // These options pre-define global variables that are exposed by popular 66 | // JavaScript libraries and runtime environments—such as browser or node.js. 67 | // Essentially they are shortcuts for explicit declarations like 68 | // /*global $:false, jQuery:false */ 69 | 70 | "browser": true, //defines globals exposed by modern browsers 71 | "couch": false, //defines globals exposed by CouchDB 72 | "devel": true, //defines globals that are usually used for logging poor-man's debugging: `console`, `alert`, etc. 73 | "dojo": false, //defines globals exposed by the Dojo Toolkit 74 | "jquery": true, //defines globals exposed by the jQuery JavaScript library 75 | "mootools": false, //defines globals exposed by the MooTools JavaScript framework 76 | "node": true, //defines globals available when your code is running inside of the Node runtime environment 77 | "nonstandard": false, //defines non-standard but widely adopted globals such as `escape` and `unescape` 78 | "phantom": false, //defines globals available when your core is running inside of the PhantomJS runtime environment 79 | "prototypejs": false, //defines globals exposed by the Prototype JavaScript framework 80 | "rhino": false, //defines globals available when your code is running inside of the Rhino runtime environment 81 | "worker": true, //defines globals available when your code is running inside of a Web Worker 82 | "wsh": false, //defines globals available when your code is running as a script for the Windows Script Host 83 | "yui": false, //defines globals exposed by the YUI JavaScript framework 84 | 85 | // LEGACY 86 | // These options are legacy from JSLint. Aside from bug fixes they will not 87 | // be improved in any way and might be removed at any point. 88 | 89 | "nomen": false, //disallows the use of dangling `_` in variables 90 | "onevar": false, //allows only one `var` statement per function 91 | "passfail": false, //makes JSHint stop on the first error or warning 92 | "white": false //make JSHint check your source code against Douglas Crockford's JavaScript coding style 93 | } 94 | --------------------------------------------------------------------------------