diff --git a/.eslintignore b/.eslintignore index bf3f05d057..6e154d061e 100755 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ node_modules/** reports/** +dist/** diff --git a/.eslintrc b/.eslintrc index b0a4cf80d4..c6b6835cb0 100755 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,5 @@ { + "parser": "babel-eslint", "env": { "node": true }, @@ -83,7 +84,7 @@ "wrap-iife": 2, "yoda": 2, // Strict Mode - "strict": [2, "global"], + "strict": [2, "never"], // Variables "no-catch-shadow": 2, "no-delete-var": 2, diff --git a/.gitignore b/.gitignore index af67fd4b29..174789b129 100755 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,4 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz -*.sublime-project -*.sublime-workspace -pids -logs reports -build +dist node_modules npm-debug.log -sftp-config.json diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..83264c1109 --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +# .npmignore so dist/ can be git-ignored but will be in npm package + +reports +# dist < must end up in npm package. do not ignore. +node_modules +npm-debug.log diff --git a/.travis.yml b/.travis.yml index b59b05d0c2..eb7f4fa0d8 100755 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,8 @@ before_script: - npm prune - 'curl -Lo travis_after_all.py https://git.io/vLSON' script: - - npm test + - npm run build + - npm run test after_success: - python travis_after_all.py - export $(cat .to_export_back) diff --git a/index.js b/index.js deleted file mode 100755 index 4fa0e80378..0000000000 --- a/index.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = { - rules: { - 'no-session': require('./lib/rules/no-session'), - 'no-blaze-lifecycle-assignment': require('./lib/rules/no-blaze-lifecycle-assignment'), - 'no-zero-timeout': require('./lib/rules/no-zero-timeout'), - 'audit-argument-checks': require('./lib/rules/audit-argument-checks') - }, - rulesConfig: { - 'no-session': 0, - 'no-blaze-lifecycle-assignment': 0, - 'no-zero-timeout': 0, - 'audit-argument-checks': 0 - } -}; diff --git a/lib/index.js b/lib/index.js new file mode 100755 index 0000000000..e7729bc281 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,14 @@ +module.exports = { + rules: { + 'no-session': require('./rules/no-session'), + 'no-blaze-lifecycle-assignment': require('./rules/no-blaze-lifecycle-assignment'), + 'no-zero-timeout': require('./rules/no-zero-timeout'), + 'audit-argument-checks': require('./rules/audit-argument-checks') + }, + rulesConfig: { + 'no-session': 0, + 'no-blaze-lifecycle-assignment': 0, + 'no-zero-timeout': 0, + 'audit-argument-checks': 0 + } +}; diff --git a/lib/rules/audit-argument-checks.js b/lib/rules/audit-argument-checks.js index bd4a8c5fb7..2ee83fe116 100644 --- a/lib/rules/audit-argument-checks.js +++ b/lib/rules/audit-argument-checks.js @@ -2,7 +2,6 @@ * @fileoverview Enforce check on all arguments passed to methods and publish functions * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Rule Definition @@ -17,14 +16,14 @@ module.exports = function (context) { function auditArgumentChecks (node) { if (node.type === 'FunctionExpression') { - var checkedParams = []; + const checkedParams = []; // short-circuit if (node.params.length === 0) { return; } - node.body.body.map(function (expression) { + node.body.body.map((expression) => { if ( expression.type === 'ExpressionStatement' && expression.expression.type === 'CallExpression' && @@ -37,7 +36,7 @@ module.exports = function (context) { } }); - node.params.map(function (param) { + node.params.map((param) => { if (param.type === 'Identifier') { if (checkedParams.indexOf(param.name) === -1) { context.report(param, param.name + ' is not checked'); @@ -53,7 +52,7 @@ module.exports = function (context) { // --------------------------------------------------------------------------- return { - CallExpression: function (node) { + CallExpression: (node) => { if ( node.callee.type === 'MemberExpression' && !node.callee.computed && @@ -83,7 +82,6 @@ module.exports = function (context) { } } }; - }; module.exports.schema = []; diff --git a/lib/rules/no-blaze-lifecycle-assignment.js b/lib/rules/no-blaze-lifecycle-assignment.js index 4e4c8f5d3e..968c751cee 100644 --- a/lib/rules/no-blaze-lifecycle-assignment.js +++ b/lib/rules/no-blaze-lifecycle-assignment.js @@ -2,7 +2,6 @@ * @fileoverview Prevent deprecated template lifecycle callback assignments. * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Rule Definition @@ -44,11 +43,11 @@ module.exports = function (context) { return { - AssignmentExpression: function (node) { + AssignmentExpression: (node) => { if (node.operator === '=') { - var lhs = node.left; + const lhs = node.left; if ( lhs.type === 'MemberExpression' && !lhs.computed && lhs.object.type === 'MemberExpression' && @@ -63,7 +62,6 @@ module.exports = function (context) { } }; - }; module.exports.schema = []; diff --git a/lib/rules/no-session.js b/lib/rules/no-session.js index af77953c73..d96fae802c 100644 --- a/lib/rules/no-session.js +++ b/lib/rules/no-session.js @@ -2,7 +2,6 @@ * @fileoverview Prevent usage of Session * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Rule Definition @@ -16,7 +15,7 @@ module.exports = function (context) { return { - MemberExpression: function (node) { + MemberExpression (node) { if (node.object.name === 'Session') { context.report(node, 'Unexpected Session statement.'); } diff --git a/lib/rules/no-zero-timeout.js b/lib/rules/no-zero-timeout.js index 4636a626ce..f919b688a2 100644 --- a/lib/rules/no-zero-timeout.js +++ b/lib/rules/no-zero-timeout.js @@ -2,7 +2,6 @@ * @fileoverview Prevent usage of Meteor.setTimeout with zero delay * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Rule Definition diff --git a/package.json b/package.json index 90edd2da17..b8ceb4526f 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,16 @@ "name": "eslint-plugin-meteor", "author": "Dominik Ferber ", "description": "Meteor specific linting rules for ESLint", - "main": "index.js", + "main": "dist/index.js", "scripts": { "coveralls": "cat ./reports/coverage/lcov.info | coveralls", "lint": "eslint ./", "test": "npm run lint && npm run unit-test", - "unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --reporter dot", - "semantic-release": "semantic-release pre && npm publish && semantic-release post" + "unit-test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --reporter dot --compilers js:babel/register", + "semantic-release": "semantic-release pre && npm publish && semantic-release post", + "prebuild": "rimraf dist && mkdir dist", + "dev": "babel lib -d dist -w", + "build": "babel lib -d dist" }, "files": [ "LICENSE", @@ -24,6 +27,7 @@ "bugs": "https://github.com/dferber90/eslint-plugin-meteor/issues", "dependencies": {}, "devDependencies": { + "babel": "5.8.23", "coveralls": "2.11.4", "cz-conventional-changelog": "1.0.1", "eslint": "1.5.1", @@ -31,7 +35,8 @@ "ghooks": "0.3.2", "istanbul": "0.3.21", "mocha": "2.3.3", - "semantic-release": "4.3.5" + "semantic-release": "4.3.5", + "rimraf": "2.4.3" }, "peerDependencies": { "eslint": ">=0.8.0" diff --git a/tests/index.js b/tests/index.js index 710d38fa8e..f8f364d3ea 100755 --- a/tests/index.js +++ b/tests/index.js @@ -1,13 +1,12 @@ /* eslint-env mocha */ -'use strict'; -var plugin = require('..'); +var plugin = require('../dist/index.js'); var assert = require('assert'); var fs = require('fs'); var path = require('path'); -var rules = fs.readdirSync(path.resolve(__dirname, '../lib/rules/')) +var rules = fs.readdirSync(path.resolve(__dirname, '../dist/rules/')) .filter(function (f) { return path.extname(f) === '.js'; }) @@ -22,7 +21,7 @@ describe('all rule files should be exported by the plugin', function() { it('should export ' + ruleName, function() { assert.equal( plugin.rules[ruleName], - require(path.join('../lib/rules', ruleName)) + require(path.join('../dist/rules', ruleName)) ); }); diff --git a/tests/lib/rules/audit-argument-checks.js b/tests/lib/rules/audit-argument-checks.js index 308f97e0e1..87aae45824 100644 --- a/tests/lib/rules/audit-argument-checks.js +++ b/tests/lib/rules/audit-argument-checks.js @@ -2,13 +2,12 @@ * @fileoverview Enforce check on all arguments passed to methods and publish functions * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Requirements // ----------------------------------------------------------------------------- -var rule = require('../../../lib/rules/audit-argument-checks'); +var rule = require('../../../dist/rules/audit-argument-checks'); var RuleTester = require('eslint').RuleTester; @@ -84,16 +83,16 @@ ruleTester.run('audit-argument-checks', rule, { parser: 'babel-eslint' }, { - code: [ - 'Meteor.methods({' + - ' foo () {},' + - ' foo2 (bar) {' + - ' if (true) {' + - ' check(bar, Meteor.any)' + - ' }' + - ' }' + - '})' - ].join('\n'), + code: ` + Meteor.methods({ + foo () {}, + foo2 (bar) { + if (true) { + check(bar, Meteor.any) + } + } + }) + `, errors: [{ message: 'bar is not checked', type: 'Identifier' diff --git a/tests/lib/rules/no-blaze-lifecycle-assignment.js b/tests/lib/rules/no-blaze-lifecycle-assignment.js index 770eb39122..60804e3388 100644 --- a/tests/lib/rules/no-blaze-lifecycle-assignment.js +++ b/tests/lib/rules/no-blaze-lifecycle-assignment.js @@ -4,15 +4,13 @@ * @copyright 2015 Dominik Ferber. All rights reserved. * See LICENSE file in root directory for full license. */ -'use strict'; // ----------------------------------------------------------------------------- // Requirements // ----------------------------------------------------------------------------- -var rule = require('../../../lib/rules/no-blaze-lifecycle-assignment'), - - RuleTester = require('eslint').RuleTester; +var rule = require('../../../dist/rules/no-blaze-lifecycle-assignment'); +var RuleTester = require('eslint').RuleTester; // ----------------------------------------------------------------------------- diff --git a/tests/lib/rules/no-session.js b/tests/lib/rules/no-session.js index 22ef8ac22d..21e28982da 100644 --- a/tests/lib/rules/no-session.js +++ b/tests/lib/rules/no-session.js @@ -4,13 +4,12 @@ * @copyright 2015 Dominik Ferber. All rights reserved. * See LICENSE file in root directory for full license. */ -'use strict'; // ----------------------------------------------------------------------------- // Requirements // ----------------------------------------------------------------------------- -var rule = require('../../../lib/rules/no-session'); +var rule = require('../../../dist/rules/no-session'); var RuleTester = require('eslint').RuleTester; diff --git a/tests/lib/rules/no-zero-timeout.js b/tests/lib/rules/no-zero-timeout.js index 37ff65e364..e1c6feadb7 100644 --- a/tests/lib/rules/no-zero-timeout.js +++ b/tests/lib/rules/no-zero-timeout.js @@ -2,13 +2,12 @@ * @fileoverview Prevent usage of Meteor.setTimeout with zero delay * @author Dominik Ferber */ -'use strict'; // ----------------------------------------------------------------------------- // Requirements // ----------------------------------------------------------------------------- -var rule = require('../../../lib/rules/no-zero-timeout'); +var rule = require('../../../dist/rules/no-zero-timeout'); var RuleTester = require('eslint').RuleTester;