mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
@@ -1,2 +1,3 @@
|
||||
node_modules/**
|
||||
reports/**
|
||||
dist/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -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
|
||||
|
||||
6
.npmignore
Normal file
6
.npmignore
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
16
index.js
16
index.js
@@ -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
|
||||
}
|
||||
};
|
||||
14
lib/index.js
Executable file
14
lib/index.js
Executable file
@@ -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
|
||||
}
|
||||
};
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* @fileoverview Prevent usage of Meteor.setTimeout with zero delay
|
||||
* @author Dominik Ferber
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
|
||||
13
package.json
13
package.json
@@ -2,13 +2,16 @@
|
||||
"name": "eslint-plugin-meteor",
|
||||
"author": "Dominik Ferber <dominik.ferber+npm@gmail.com>",
|
||||
"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"
|
||||
|
||||
@@ -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))
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user