Skip to content

Commit 8128c6b

Browse files
committed
Add Eslint to this project
1 parent b467f9b commit 8128c6b

16 files changed

Lines changed: 624 additions & 180 deletions

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test/fixtures
2+
test/helpers

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
'env': {
3+
'browser': true,
4+
'node': true,
5+
'es6': true,
6+
},
7+
'extends': ['eslint:recommended', 'plugin:node/recommended'],
8+
'parserOptions': {
9+
'ecmaVersion': 6
10+
},
11+
'rules': {
12+
'no-console': ['error', { 'allow': ['warn', 'error']}],
13+
'linebreak-style': [
14+
'error',
15+
'unix'
16+
],
17+
'semi': [
18+
'error',
19+
'always'
20+
]
21+
}
22+
};

.jshintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
"main": "src/index.js",
66
"scripts": {
77
"changelog": "lerna-changelog",
8+
"lint": "node_modules/.bin/eslint src test",
89
"test": "mocha",
9-
"preversion": "npm test",
10+
"preversion": "npm lint && npm test",
1011
"postversion": "git push origin master --tags"
1112
},
1213
"repository": {
1314
"type": "git",
1415
"url": "git+https://github.com/ember-fastboot/fastboot.git"
1516
},
1617
"engines": {
17-
"node": ">= 6.0.0"
18+
"node": "^6.14.0 || ^8.10.0 || >=9.10.0"
1819
},
1920
"keywords": [
2021
"ember",
@@ -40,10 +41,13 @@
4041
"chai": "^4.1.0",
4142
"chai-as-promised": "^7.1.1",
4243
"ember-source": "3.2.0",
44+
"eslint": "^5.10.0",
45+
"eslint-plugin-chai-expect": "^2.0.1",
46+
"eslint-plugin-mocha": "^5.2.0",
47+
"eslint-plugin-node": "^8.0.0",
4348
"express": "^4.15.4",
4449
"lerna-changelog": "^0.8.2",
4550
"mocha": "^5.2.0",
46-
"mocha-jshint": "^2.3.1",
4751
"rimraf": "^2.6.2",
4852
"temp": "^0.8.3"
4953
}

src/result.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Result {
171171
body = HTMLSerializer.serializeChildren(body);
172172

173173
this._head = head;
174-
174+
175175
// Adding script boundary around the body
176176
this._body = `<script type="x/boundary" id="fastboot-body-start"></script>${body}<script type="x/boundary" id="fastboot-body-end"></script>`;
177177
}
@@ -186,7 +186,7 @@ function insertIntoIndexHTML(html, htmlAttributes, head, body, bodyAttributes) {
186186
let isBodyReplaced = false;
187187
let isHeadReplaced = false;
188188

189-
html = html.replace(/<\!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function(match, tag) {
189+
html = html.replace(/<!-- EMBER_CLI_FASTBOOT_(HEAD|BODY) -->/g, function(match, tag) {
190190
if (tag === 'HEAD' && head && !isHeadReplaced) {
191191
isHeadReplaced = true;
192192
return head;

test/.eslintrc.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = {
2+
plugins: [
3+
'chai-expect',
4+
'mocha'
5+
],
6+
env: {
7+
mocha: true,
8+
},
9+
rules: {
10+
// JSHint "expr", disabled due to chai expect assertions
11+
'no-unused-expressions': 0,
12+
13+
// disabled for easier asserting of file contents
14+
'quotes': 0,
15+
16+
// disabled because describe(), it(), etc. should not use arrow functions
17+
'prefer-arrow-callback': 0,
18+
19+
/*** chai-expect ***/
20+
21+
'chai-expect/missing-assertion': 2,
22+
'chai-expect/terminating-properties': 2,
23+
'chai-expect/no-inner-compare': 2,
24+
25+
/*** mocha ***/
26+
27+
'mocha/no-exclusive-tests': 'error',
28+
'mocha/no-skipped-tests': 'off',
29+
'mocha/no-pending-tests': 'off',
30+
'mocha/handle-done-callback': 'error',
31+
'mocha/no-synchronous-tests': 'off',
32+
'mocha/no-global-tests': 'error',
33+
'mocha/no-return-and-callback': 'error',
34+
'mocha/valid-test-description': 'off',
35+
'mocha/valid-suite-description': 'off',
36+
'mocha/no-sibling-hooks': 'error',
37+
'mocha/no-mocha-arrows': 'error',
38+
'mocha/no-hooks': 'off',
39+
'mocha/no-hooks-for-single-case': 'off',
40+
'mocha/no-top-level-hooks': 'error',
41+
'mocha/no-identical-title': 'error',
42+
'mocha/max-top-level-suites': 'off',
43+
'mocha/no-nested-tests': 'error'
44+
}
45+
};

test/.jshintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/fastboot-dependencies-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
const expect = require('chai').expect;
4-
const fs = require('fs');
5-
const path = require('path');
64
const fixture = require('./helpers/fixture-path');
75
const FastBoot = require('./../src/index');
86

test/fastboot-headers-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* jshint expr:true */
22

33
var expect = require('chai').expect;
4-
var path = require('path');
54
var FastBootHeaders = require('./../src/fastboot-headers.js');
65
var Ember = require('ember-source/dist/ember.debug');
76

0 commit comments

Comments
 (0)