Skip to content

Commit

Permalink
feat: Add prettier for node 6 config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Aug 25, 2017
1 parent 559c99f commit 98ce778
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
10 changes: 5 additions & 5 deletions examples/eslint/node6/comma-dangle.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict';

function foo() { }
function foo() {}

// no comma-dangle for functions
foo(
1,
2
'some very long argument to force line break',
'another very long argument to force line break'
);

// yes comma-dangle for arrays/objects
foo([
1,
2,
'some very long argument to force line break',
'another very long argument to force line break',
]);
foo({
x: 1,
Expand Down
4 changes: 3 additions & 1 deletion examples/eslint/node6/generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';

function* foo() { yield 42; }
function* foo() {
yield 42;
}
foo();
12 changes: 12 additions & 0 deletions examples/eslint/node6/ugly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

'use strict';
function f (){

const x = 42;
return 2 * x;



}

f () ;
8 changes: 8 additions & 0 deletions examples/eslint/node6/ugly.out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

function f() {
const x = 42;
return 2 * x;
}

f();
18 changes: 12 additions & 6 deletions node6.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ module.exports = {
},
plugins: [
'node',
'prettier',
],
rules: {
'node/no-unsupported-features': [2, { version: 6 }],
// Random stylistic choices
'prettier/prettier': ['error', {
singleQuote: true,
trailingComma: 'es5',
}],
'lines-around-directive': ['error', 'always'],

// Code convention
'no-underscore-dangle': [2, { allowAfterThis: true }],

// Bug prevention
strict: [2, 'global'],
'comma-dangle': [2, {
arrays: 'always-multiline',
objects: 'always-multiline',
functions: 'never',
}],
'node/no-unsupported-features': [2, { version: 6 }],
}
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
"coffeelint-use-strict": "^1.0.0",
"coffeescope2": "~0.4.2",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^2.0.0"
"eslint-plugin-node": "^2.0.0",
"eslint-plugin-prettier": "^2.1.2"
},
"devDependencies": {
"coffee-script": "^1.10.0",
"coffeelint": "^1.15.7",
"eslint": "^4.4.1",
"globby": "^6.1.0",
"mocha": "^3.5.0",
"prettier": "^1.5.3",
"stylint": "^1.5.7"
}
}
9 changes: 7 additions & 2 deletions test/lint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ const GROUPS = [
if (e.code !== 'ENOENT') throw e;
}

assert.equal(first.errorCount, expected.errorCount);
try {
assert.equal(first.errorCount, expected.errorCount);
} catch (e) {
console.log(first.messages, expected.messages);
throw e;
}

let expectedSource;
try {
Expand All @@ -37,7 +42,7 @@ const GROUPS = [
expectedSource = content;
}

assert.equal(expectedSource, first.source || content);
assert.equal(expectedSource, first.output || content);
},
},
];
Expand Down

0 comments on commit 98ce778

Please sign in to comment.