Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test elias rules #222

Merged
merged 7 commits into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions rules/node_common_js.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
module.exports = {
"no-sync": "off", // https://github.com/dwyl/goodparts/issues/144
"no-restricted-properties": "off", // https://github.com/dwyl/goodparts/issues/143
"no-restricted-modules": "off", // https://github.com/dwyl/goodparts/issues/139
"no-process-exit": "error", // https://github.com/dwyl/goodparts/issues/136
"no-process-env": "off", // https://github.com/dwyl/goodparts/issues/134
"no-path-concat": "error", // https://github.com/dwyl/goodparts/issues/132
"no-new-require": "error", // https://github.com/dwyl/goodparts/issues/129
"no-mixed-requires": ["error", { "grouping": true, "allowCall": false }], // https://github.com/dwyl/goodparts/issues/126
"handle-callback-err": ["error", "^(error|err\d*)$"], // https://github.com/dwyl/goodparts/issues/121
"global-require": "error", // https://github.com/dwyl/goodparts/issues/119
"callback-return": ["error", ["done", "next", "callback", "cb"]], // https://github.com/dwyl/goodparts/issues/112
};
28 changes: 28 additions & 0 deletions rules/stylistic_issues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
module.exports = {
"space-infix-ops": ["error", {"int32Hint": false}], // https://github.com/dwyl/goodparts/issues/32
"max-len": ["error", 80], // https://github.com/dwyl/goodparts/issues/186
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate max-len

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this one as other is more exact

"array-bracket-spacing": ["error", "never"], // https://github.com/dwyl/goodparts/issues/219
"block-spacing": "error", // https://github.com/dwyl/goodparts/issues/218
"brace-style": ["error", "1tbs", { "allowSingleLine": true }], // https://github.com/dwyl/goodparts/issues/217
"camelcase": "error", // https://github.com/dwyl/goodparts/issues/216
"comma-style": ["error", "last"], // https://github.com/dwyl/goodparts/issues/215
"comma-spacing": ["error", { "before": false, "after": true }], // https://github.com/dwyl/goodparts/issues/214
"comma-dangle": ["error", "never"], // https://github.com/dwyl/goodparts/issues/213
"computed-property-spacing": ["error", "never"], // https://github.com/dwyl/goodparts/issues/212
"consistent-this": "off", // https://github.com/dwyl/goodparts/issues/211
"eol-last": "error", // https://github.com/dwyl/goodparts/issues/210
"func-call-spacing": ["error", "never"], // https://github.com/dwyl/goodparts/issues/209
"func-names": "off", // https://github.com/dwyl/goodparts/issues/208
"func-style": "off", // https://github.com/dwyl/goodparts/issues/207
"id-blacklist": "off", // https://github.com/dwyl/goodparts/issues/205
"id-length": "off", // https://github.com/dwyl/goodparts/issues/204
"id-match": "off", // https://github.com/dwyl/goodparts/issues/202
"indent": ["error", 4], // https://github.com/dwyl/goodparts/issues/201
"jsx-quotes": "off", // https://github.com/dwyl/goodparts/issues/199
"padded-blocks": ["error", "never"], // https://github.com/dwyl/goodparts/issues/55
"quote-props": ["error", "consistent-as-needed", { "keywords": false }], // https://github.com/dwyl/goodparts/issues/54
"quotes": ["error", "single", {"avoidEscape": false, "allowTemplateLiterals": false}], // https://github.com/dwyl/goodparts/issues/53
"semi-spacing": ["error", {"before": false, "after": true}], // https://github.com/dwyl/goodparts/issues/50
"sort-keys": "off", // https://github.com/dwyl/goodparts/issues/39
"sort-vars": "off", // https://github.com/dwyl/goodparts/issues/38
"space-in-parens": ["error", "never"], // https://github.com/dwyl/goodparts/issues/34
"spaced-comment": ["error", "always"], // https://github.com/dwyl/goodparts/issues/20
"wrap-regex": "off", // https://github.com/dwyl/goodparts/issues/17
"max-len": ["error", {
code: 80,
ignoreTrailingComments: true,
Expand Down
4 changes: 4 additions & 0 deletions rules/variables.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
module.exports = {
"no-use-before-define": "error", // https://github.com/dwyl/goodparts/issues/153
"no-undefined": "error", // https://github.com/dwyl/goodparts/issues/152
"no-undef-init": "error", // https://github.com/dwyl/goodparts/issues/151
"no-shadow-restricted-names": "error", // https://github.com/dwyl/goodparts/issues/150
};
6 changes: 6 additions & 0 deletions test/fixtures/brace-style.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (foo) {
bar();
}
else {
baz();
}
5 changes: 5 additions & 0 deletions test/fixtures/brace-style.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (foo) {
bar();
} else {
baz();
}
5 changes: 5 additions & 0 deletions test/fixtures/callback-return.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function foo(err, callback) {
if (err) {
callback(err);
}
}
5 changes: 5 additions & 0 deletions test/fixtures/callback-return.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function foo(err, callback) {
if (err) {
return callback(err);
}
}
2 changes: 2 additions & 0 deletions test/fixtures/comma-style.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var foo = 1
, bar = 2;
2 changes: 2 additions & 0 deletions test/fixtures/comma-style.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var foo = 1,
bar = 2;
3 changes: 3 additions & 0 deletions test/fixtures/eol.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function doSmth() {
var foo = 2;
}
3 changes: 3 additions & 0 deletions test/fixtures/eol.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function doSmth() {
var foo = 2;
}
5 changes: 5 additions & 0 deletions test/fixtures/global-require.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function foo() {
if (condition) {
var fs = require("fs");
}
}
3 changes: 3 additions & 0 deletions test/fixtures/handle-callback-err.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function loadData (err, data) {
doSomething();
}
6 changes: 6 additions & 0 deletions test/fixtures/handle-callback-err.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function loadData (err, data) {
if (err) {
console.log(err.stack);
}
doSomething();
}
6 changes: 6 additions & 0 deletions test/fixtures/ident.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (a) {
b=c;
function foo(d) {
e=f;
}
}
6 changes: 6 additions & 0 deletions test/fixtures/ident.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if (a) {
b=c;
function foo(d) {
e=f;
}
}
2 changes: 2 additions & 0 deletions test/fixtures/no-mixed-requires.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var fs = require('fs'),
async = require('async');
2 changes: 2 additions & 0 deletions test/fixtures/no-use-before-define.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alert(a);
var a = 10;
2 changes: 2 additions & 0 deletions test/fixtures/no-use-before-define.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var a = 10;
alert(a);
30 changes: 29 additions & 1 deletion test/fixtures/node_common_js.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
var read = require('../read.js');

module.exports = {};
module.exports = {
'no-sync': null,
'no-restricted-properties': null,
'no-restricted-modules': null,
'no-process-exit': {
fail: ['process.exit(1);']
},
'no-process-env': null,
'no-path-concat': {
fail: ['var fullPath = __dirname + "/foo.js";']
},
'no-new-require': {
fail: ['var mod = new require("mod");']
},
'no-mixed-requires': {
fail: [read('no-mixed-requires.fail')],
},
'handle-callback-err': {
fail: [read('handle-callback-err.fail')],
pass: [read('handle-callback-err.pass')]
},
'global-require': {
fail: [read('global-require.fail')]
},
'callback-return': {
fail: [read('callback-return.fail')],
pass: [read('callback-return.pass')]
}
};
5 changes: 5 additions & 0 deletions test/fixtures/padded-blocks.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (a) {

b();

}
3 changes: 3 additions & 0 deletions test/fixtures/padded-blocks.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (a) {
b();
}
4 changes: 4 additions & 0 deletions test/fixtures/quote-props.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var object = {
"foo": 'bar',
baz: 42
};
4 changes: 4 additions & 0 deletions test/fixtures/quote-props.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var object = {
foo: 'bar',
baz: 42
};
1 change: 1 addition & 0 deletions test/fixtures/quotes.fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var double = "double";
1 change: 1 addition & 0 deletions test/fixtures/quotes.pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var nodouble = 'double';
80 changes: 79 additions & 1 deletion test/fixtures/stylistic_issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,83 @@ module.exports = {
'space-infix-ops': {
fail: ['var a = 1+ 2;'],
pass: ['var a = 1 + 2;']
}
},
'array-bracket-spacing': {
fail: ['[ 1, 2, 3 ]'],
pass: ['[1, 2, 3]']
},
'block-spacing': {
fail: ['{var a =2; }'],
pass: ['{var a =2;}']
},
'brace-style': {
fail: [read('brace-style.fail')],
pass: [read('brace-style.pass')]
},
'camelcase': {
fail: ['var camel_case = 42;'],
pass: ['var camelCase = 42;']
},
'comma-style': {
fail: [read('comma-style.fail')],
pass: [read('comma-style.pass')]
},
'comma-spacing': {
fail: ['var a = 2 , b = 3;'],
pass: ['var a = 2, b = 3;']
},
'comma-dangle': {
fail: ['var a = [1, 2,];'],
pass: ['var a = [1, 2];']
},
'computed-property-spacing': {
fail: ['obj[ "foo" ];'],
pass: ['obj["foo"];']
},
'consistent-this': null,
'eol-last': {
fail: [read('eol.fail')],
pass: [read('eol.pass')]
},
'func-call-spacing': {
fail: ['fn ();'],
pass: ['fn();']
},
'func-names': null,
'func-style': null,
'id-blacklist': null,
'id-length': null,
'id-match': null,
'indent': {
fail: [read('ident.fail')],
pass: [read('ident.pass')]
},
'jsx-quotes': null,
'padded-blocks': {
fail: [read('padded-blocks.fail')],
pass: [read('padded-blocks.pass')]
},
'quote-props': {
fail: [read('quote-props.fail')],
pass: [read('quote-props.pass')]
},
'quotes': {
fail: [read('quotes.fail')],
pass: [read('quotes.pass')]
},
'semi-spacing': {
fail: ['var a = 2 ;', 'var foo;var bar;'],
pass: ['var a = 2;', 'var foo; var bar;']
},
'sort-keys': null,
'sort-vars': null,
'space-in-parens': {
fail: ['foo( "bar" );'],
pass: ['foo("ba");']
},
'spaced-comment': {
fail: ['//no space'],
pass: ['// yes!']
},
'wrap-regex': null
};
17 changes: 16 additions & 1 deletion test/fixtures/variables.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
var read = require('../read.js');

module.exports = {};
module.exports = {
'no-use-before-define': {
fail: [read('no-use-before-define.fail')],
pass: [read('no-use-before-define.pass')]
},
'no-undefined': {
fail: ['var undefined = "bob";']
},
'no-undef-init': {
fail: ['var a = undefined;'],
pass: ['var a;']
},
'no-shadow-restricted-names': {
fail: ['function NaN(){};']
}
};