Skip to content

Commit

Permalink
[tests] add test for es5 prettier formated
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Jul 18, 2017
1 parent 97e2c8a commit 8a841fd
Show file tree
Hide file tree
Showing 178 changed files with 2,645 additions and 45 deletions.
94 changes: 49 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
{
"name": "@namics/eslint-config",
"version": "4.0.0",
"description": "Default configurations for eslint",
"author": "Simon Mollweide <simon.mollweide@namics.com>",
"license": "MIT",
"private": false,
"engines": {
"node": ">=4 <9",
"npm": ">=3 <6"
"name": "@namics/eslint-config",
"version": "4.0.0",
"description": "Default configurations for eslint",
"author": "Simon Mollweide <simon.mollweide@namics.com>",
"license": "MIT",
"private": false,
"engines": {
"node": ">=4 <9",
"npm": ">=3 <6"
},
"repository": {
"type": "git",
"url": "https://github.com/namics/eslint-config-namics.git"
},
"bugs": {
"url": "https://github.com/namics/eslint-config-namics/issues"
},
"main": "configurations/es6-browser.js",
"scripts": {
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint .",
"test": "npm run lint",
"prettier": "node_modules/.bin/prettier --write \"test/es5-disable-styles/**/*.js\""
},
"keywords": [
"code checker",
"code linter",
"code standards",
"code style",
"eslint-config",
"eslint",
"eslintconfig",
"lint",
"es2015",
"react",
"jsx"
],
"devDependencies": {
"prettier": "^1.5.3"
},
"repository": {
"type": "git",
"url": "https://github.com/namics/eslint-config-namics.git"
},
"bugs": {
"url": "https://github.com/namics/eslint-config-namics/issues"
},
"main": "configurations/es6-browser.js",
"scripts": {
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint .",
"test": "npm run lint"
},
"keywords": [
"code checker",
"code linter",
"code standards",
"code style",
"eslint-config",
"eslint",
"eslintconfig",
"lint",
"es2015",
"react",
"jsx"
],
"dependencies": {
"babel-eslint": "7.2.3",
"eslint": "4.2.0",
"eslint-find-rules": "3.1.1",
"eslint-plugin-flowtype": "2.35.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.1.0",
"flow-bin": "0.50.0"
}
"dependencies": {
"babel-eslint": "7.2.3",
"eslint": "4.2.0",
"eslint-find-rules": "3.1.1",
"eslint-plugin-flowtype": "2.35.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.1.0",
"flow-bin": "0.50.0"
}
}
6 changes: 6 additions & 0 deletions test/es5-disable-styles/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: [
"../../configurations/es5-browser.js",
"../../configurations/es5-browser-disable-styles.js"
]
};
26 changes: 26 additions & 0 deletions test/es5-disable-styles/rules/best-practices/accessor-pairs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// DESCRIPTION = enforces getter/setter pairs in objects
// STATUS = 0

// <!START
var example;

// Bad
example = {
set a(value) {
this.val = value;
}
};

// Good
example = {
set a(value) {
this.val = value;
},
get a() {
return this.val;
}
};
// END!>

document.window.append(example.toString(), null);
document.window.append(example.toString(), null);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// DESCRIPTION = enforces return statements in callbacks of array's methods
// STATUS = 2

// <!START

/*
// Bad
var bar = [1, 2].filter(function (x) {
if (x) {
return;
}
document.window.append('', null);
});
*/

// Good
var bar = [1, 2].filter(function(x) {
if (x) {
return false;
}

document.window.append("", null);
return true;
});

// END!>
document.window.append(bar.toString(), null);
35 changes: 35 additions & 0 deletions test/es5-disable-styles/rules/best-practices/block-scoped-var.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// DESCRIPTION = treat var statements as if they were block scoped
// STATUS = 2

/* eslint vars-on-top: 0*/
/* eslint no-constant-condition: 0*/
var example;
// <!START
// Bad
/*
example = {
doIf: function () {
if (1 === 2) {
var build = true;
}
document.window.append(build.toString(), null);
}
};
*/

// Good
example = {
doIf: function() {
var build = true;

if (1 === 2) {
build = false;
}

document.window.append(build.toString(), null);
}
};

// END!>
document.window.append(example.doIf, null);
57 changes: 57 additions & 0 deletions test/es5-disable-styles/rules/best-practices/complexity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// DESCRIPTION = specify the maximum cyclomatic complexity allowed in a program
// STATUS = 2

/* eslint no-unused-vars: 0*/
/* eslint require-jsdoc: 0*/
/* eslint no-else-return: 0*/
/* eslint no-constant-condition: 0*/
// <!START

// Bad
/*
function a(x) {
if (1 === 2) {
return x; // 1st path
} else if (2 === 3) {
return x + 1; // 2nd path
} else if (2 === 3) {
return x + 2; // 3nd path
} else if (2 === 3) {
return x + 3; // 4nd path
} else if (2 === 3) {
return x + 4; // 5nd path
} else if (2 === 3) {
return x + 5; // 6nd path
} else if (2 === 3) {
return x + 6; // 7nd path
} else if (2 === 3) {
return x + 7; // 8nd path
} else if (2 === 3) {
return x + 8; // 9nd path
} else if (2 === 3) {
return x + 9; // 10nd path
} else if (2 === 3) {
return x + 10; // 11nd path
} else {
return 99;
}
}
*/

// Good
function b(x) {
switch (x) {
case x === 0:
return x + 1;
case x === 1:
return x + 2;
case x === 2:
return x + 3;
case x === 3:
return x + 4;
default:
return 99;
}
}

// END!>
27 changes: 27 additions & 0 deletions test/es5-disable-styles/rules/best-practices/consistent-return.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// DESCRIPTION = require return statements to either always or never specify values
// STATUS = 0

/* eslint no-unused-vars: 0*/
/* eslint require-jsdoc: 0*/
/* eslint no-else-return: 0*/
/* eslint no-redeclare: 0*/
// <!START
// Bad
function doSomething(condition) {
if (condition) {
return true;
} else {
return;
}
}

// Good
function doSomething(condition) {
if (condition) {
return true;
} else {
return false;
}
}
// END!>
document.window.append("", null);
16 changes: 16 additions & 0 deletions test/es5-disable-styles/rules/best-practices/curly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// DESCRIPTION = specify curly brace conventions for all control statements
// STATUS = 2

var foo;
// <!START
// Bad
/*
if (foo) foo++;
*/

// Good
if (foo) {
foo++;
}
// END!>
document.window.append("", null);
33 changes: 33 additions & 0 deletions test/es5-disable-styles/rules/best-practices/default-case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// DESCRIPTION = require default case in switch statements
// STATUS = 2

/* eslint no-undef: 0*/
// <!START
// Bad
/*
switch (foo) {
case 1:
doSomething();
break;
case 2:
doSomething();
break;
}
*/

// Good
switch (foo) {
case 1:
doSomething();
break;

case 2:
doSomething();
break;

default:
// do nothing
}
// END!>
document.window.append("", null);
14 changes: 14 additions & 0 deletions test/es5-disable-styles/rules/best-practices/dot-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// DESCRIPTION = enforces consistent newlines before or after dots
// STATUS = 0

/* eslint no-unused-vars: 0*/
/* eslint no-undef: 0*/
/* eslint one-var: 0*/
// <!START
// Bad
var b = universe.galaxy;

// Good
var a = universe.galaxy;
// END!>
document.window.append("", null);
18 changes: 18 additions & 0 deletions test/es5-disable-styles/rules/best-practices/dot-notation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// DESCRIPTION = encourages use of dot notation whenever possible
// STATUS = 2

/* eslint no-unused-vars: 0*/
/* eslint no-undef: 0*/
/* eslint no-redeclare: 0*/
/* eslint one-var: 0*/
// <!START
// Bad
/*
var x = foo['bar'];
*/

// Good
var x = foo.bar;
var x = foo[bar];
// END!>
document.window.append("", null);
17 changes: 17 additions & 0 deletions test/es5-disable-styles/rules/best-practices/eqeqeq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// DESCRIPTION = require the use of === and !==
// STATUS = 2

/* eslint no-undef: 0*/
/* eslint no-empty: 0*/
// <!START
// Bad
/*
if (x == 42) {
}
*/
// Good
if (x === 42) {
}
// END!>
document.window.append("", null);
Loading

0 comments on commit 8a841fd

Please sign in to comment.