Skip to content

Commit bb700c5

Browse files
authored
Start linting all test/ files as part of test script (#704)
In an effort of ensuring consistent code style in test files as with the "production" source code, we should run eslint as part of the `$ npm test` script as well. Most of the related fixes was done by `eslint` using the `--fix` argument. Only special configuration tweaks for tests compared to the other source code, is to allow functions declaration without names. The rationale for allowing that in tests, is that the important reason we have them in the source code (proper stacktraces) aren't as important in test files.
1 parent 11ac71a commit bb700c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+225
-219
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"npm": ">=1.4.0"
3333
},
3434
"scripts": {
35-
"pretest": "eslint mustache.js bin/mustache",
35+
"pretest": "eslint mustache.js bin/mustache test/**/*.js",
3636
"test": "mocha --reporter spec test/*-test.js",
3737
"test-render": "mocha --reporter spec test/render-test",
3838
"pre-test-browser": "node test/create-browser-suite.js",

test/.eslintrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../.eslintrc",
3+
"rules": {
4+
"func-names": 0
5+
}
6+
}

test/_files/ampersand_escape.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
({
2-
message: "Some <code>"
3-
})
2+
message: 'Some <code>'
3+
});

test/_files/apostrophe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
({
22
'apos': "'",
33
'control': 'X'
4-
})
4+
});

test/_files/array_of_strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
({
22
array_of_strings: ['hello', 'world']
3-
})
3+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
({
22
valueOf: 'Avoids methods',
33
watch: 'in Object.prototype'
4-
})
4+
});

test/_files/backslashes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
({
2-
value: "\\abc"
3-
})
2+
value: '\\abc'
3+
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
({
2-
tag: "yo"
3-
})
2+
tag: 'yo'
3+
});

test/_files/bug_length_property.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
({
22
length: 'hello'
3-
})
3+
});

test/_files/changing_delimiters.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
({
2-
"foo": "foooooooooooooo",
3-
"bar": "<b>bar!</b>"
4-
})
2+
'foo': 'foooooooooooooo',
3+
'bar': '<b>bar!</b>'
4+
});

0 commit comments

Comments
 (0)