Skip to content

Commit 16dde11

Browse files
committed
Various cleanups and updates
- Switch ESLint for JSHint - Start enforcing the use of newer syntax (as long as it's Node v4 compatible) - Add .editorconfig - Remove old dependencies no longer needed as of bb51e07 - Add package-lock.json - Use inline Markdown links in the readme
1 parent 0dfd211 commit 16dde11

13 files changed

+1529
-205
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 4
10+
11+
[.eslintrc.json]
12+
indent_size = 2

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage/

.eslintrc.json

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"node": true,
5+
"es6": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": 6
9+
},
10+
"rules": {
11+
// Possible errors
12+
"comma-dangle": ["error", "never"],
13+
"no-cond-assign": ["error", "except-parens"],
14+
"no-console": "error",
15+
"no-constant-condition": "error",
16+
"no-control-regex": "error",
17+
"no-debugger": "error",
18+
"no-dupe-args": "error",
19+
"no-dupe-keys": "error",
20+
"no-duplicate-case": "error",
21+
"no-empty": "error",
22+
"no-empty-character-class": "error",
23+
"no-ex-assign": "error",
24+
"no-extra-boolean-cast": "error",
25+
"no-extra-parens": ["error", "all", { "conditionalAssign": false, "nestedBinaryExpressions": false }],
26+
"no-extra-semi": "error",
27+
"no-func-assign": "error",
28+
"no-inner-declarations": "off",
29+
"no-invalid-regexp": "error",
30+
"no-irregular-whitespace": "error",
31+
"no-negated-in-lhs": "error",
32+
"no-obj-calls": "error",
33+
"no-regex-spaces": "error",
34+
"no-sparse-arrays": "error",
35+
"no-unexpected-multiline": "error",
36+
"no-unreachable": "error",
37+
"no-unsafe-finally": "off",
38+
"use-isnan": "error",
39+
"valid-jsdoc": "off",
40+
"valid-typeof": "error",
41+
42+
// Best practices
43+
"accessor-pairs": "error",
44+
"array-callback-return": "error",
45+
"block-scoped-var": "off",
46+
"complexity": "off",
47+
"consistent-return": "error",
48+
"curly": ["error", "all"],
49+
"default-case": "off",
50+
"dot-location": ["error", "property"],
51+
"dot-notation": "error",
52+
"eqeqeq": "error",
53+
"guard-for-in": "off",
54+
"no-alert": "error",
55+
"no-caller": "error",
56+
"no-case-declarations": "error",
57+
"no-div-regex": "off",
58+
"no-else-return": "error",
59+
"no-empty-function": "error",
60+
"no-empty-pattern": "error",
61+
"no-eq-null": "error",
62+
"no-eval": "error",
63+
"no-extend-native": "error",
64+
"no-extra-bind": "error",
65+
"no-extra-label": "error",
66+
"no-fallthrough": "error",
67+
"no-floating-decimal": "error",
68+
"no-implicit-coercion": "error",
69+
"no-implicit-globals": "error",
70+
"no-implied-eval": "off",
71+
"no-invalid-this": "error",
72+
"no-iterator": "error",
73+
"no-labels": ["error", { "allowLoop": true }],
74+
"no-lone-blocks": "error",
75+
"no-loop-func": "off",
76+
"no-magic-numbers": "off",
77+
"no-multi-spaces": "error",
78+
"no-multi-str": "error",
79+
"no-native-reassign": "error",
80+
"no-new": "error",
81+
"no-new-func": "error",
82+
"no-new-wrappers": "error",
83+
"no-octal": "error",
84+
"no-octal-escape": "error",
85+
"no-param-reassign": "off",
86+
"no-process-env": "error",
87+
"no-proto": "error",
88+
"no-redeclare": "error",
89+
"no-return-assign": ["error", "except-parens"],
90+
"no-script-url": "off",
91+
"no-self-assign": "error",
92+
"no-self-compare": "error",
93+
"no-sequences": "error",
94+
"no-throw-literal": "error",
95+
"no-unmodified-loop-condition": "error",
96+
"no-unused-expressions": "error",
97+
"no-unused-labels": "error",
98+
"no-useless-call": "error",
99+
"no-useless-concat": "error",
100+
"no-useless-escape": "error",
101+
"no-void": "error",
102+
"no-warning-comments": "off",
103+
"no-with": "error",
104+
"radix": ["error", "as-needed"],
105+
"vars-on-top": "off",
106+
"wrap-iife": ["error", "outside"],
107+
"yoda": ["error", "never"],
108+
109+
// Strict Mode
110+
"strict": ["error", "global"],
111+
112+
// Variables
113+
"init-declarations": "off",
114+
"no-catch-shadow": "error",
115+
"no-delete-var": "error",
116+
"no-label-var": "error",
117+
"no-restricted-globals": "off",
118+
"no-shadow": "error",
119+
"no-shadow-restricted-names": "error",
120+
"no-undef": "error",
121+
"no-undef-init": "error",
122+
"no-undefined": "off",
123+
"no-unused-vars": "error",
124+
"no-use-before-define": ["error", "nofunc"],
125+
126+
// Node.js and CommonJS
127+
"callback-return": "off",
128+
"global-require": "error",
129+
"handle-callback-err": "error",
130+
"no-mixed-requires": ["error", true],
131+
"no-new-require": "error",
132+
"no-path-concat": "error",
133+
"no-process-exit": "error",
134+
"no-restricted-imports": "off",
135+
"no-restricted-modules": "off",
136+
"no-sync": "off",
137+
138+
// Stylistic Issues
139+
"array-bracket-spacing": ["error", "never"],
140+
"block-spacing": ["error", "always"],
141+
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
142+
"camelcase": ["error", { "properties": "always" }],
143+
"comma-spacing": ["error", { "before": false, "after": true }],
144+
"comma-style": ["error", "last"],
145+
"computed-property-spacing": ["error", "never"],
146+
"consistent-this": "off",
147+
"eol-last": "error",
148+
"func-names": "off",
149+
"func-style": ["error", "declaration"],
150+
"id-blacklist": "off",
151+
"id-length": "off",
152+
"id-match": "off",
153+
"indent": ["error", 4, { "SwitchCase": 1 }],
154+
"jsx-quotes": "off",
155+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
156+
"keyword-spacing": ["error", { "before": true, "after": true }],
157+
"linebreak-style": ["error", "unix"],
158+
"lines-around-comment": "off",
159+
"max-depth": "off",
160+
"max-len": ["error", 120, { "ignoreUrls": true }],
161+
"max-nested-callbacks": "off",
162+
"max-params": "off",
163+
"max-statements": "off",
164+
"max-statements-per-line": ["error", { "max": 1 }],
165+
"new-cap": "error",
166+
"new-parens": "error",
167+
"newline-after-var": "off",
168+
"newline-before-return": "off",
169+
"newline-per-chained-call": "off",
170+
"no-array-constructor": "error",
171+
"no-bitwise": "off",
172+
"no-continue": "off",
173+
"no-inline-comments": "off",
174+
"no-lonely-if": "error",
175+
"no-mixed-spaces-and-tabs": "error",
176+
"no-multiple-empty-lines": "error",
177+
"no-negated-condition": "off",
178+
"no-nested-ternary": "error",
179+
"no-new-object": "error",
180+
"no-plusplus": "off",
181+
"no-restricted-syntax": "off",
182+
"no-spaced-func": "error",
183+
"no-ternary": "off",
184+
"no-trailing-spaces": "error",
185+
"no-underscore-dangle": "off",
186+
"no-unneeded-ternary": "error",
187+
"no-whitespace-before-property": "error",
188+
"object-curly-spacing": ["error", "always"],
189+
"one-var": ["error", "never"],
190+
"one-var-declaration-per-line": ["error", "initializations"],
191+
"operator-assignment": ["error", "always"],
192+
"operator-linebreak": ["error", "after"],
193+
"padded-blocks": ["error", "never"],
194+
"quote-props": ["error", "as-needed"],
195+
"quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
196+
"require-jsdoc": "off",
197+
"semi": ["error", "always"],
198+
"semi-spacing": "error",
199+
"sort-imports": "off",
200+
"sort-vars": "off",
201+
"space-before-blocks": ["error", "always"],
202+
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }],
203+
"space-in-parens": ["error", "never"],
204+
"space-infix-ops": "error",
205+
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
206+
"spaced-comment": ["error", "always", { "markers": ["///"] }],
207+
"wrap-regex": "off",
208+
209+
// ECMAScript 6
210+
"arrow-body-style": "off", // meh
211+
"arrow-parens": ["error", "as-needed"],
212+
"arrow-spacing": "error",
213+
"constructor-super": "error",
214+
"generator-star-spacing": ["error", "after"],
215+
"no-class-assign": "error",
216+
"no-confusing-arrow": "off",
217+
"no-const-assign": "error",
218+
"no-dupe-class-members": "error",
219+
"no-duplicate-imports": "error",
220+
"no-new-symbol": "error",
221+
"no-this-before-super": "error",
222+
"no-useless-computed-key": "error",
223+
"no-useless-constructor": "error",
224+
"no-var": "error",
225+
"object-shorthand": "error",
226+
"prefer-arrow-callback": "error",
227+
"prefer-const": "error",
228+
"prefer-reflect": "off",
229+
"prefer-rest-params": "off",
230+
"prefer-spread": "off",
231+
"prefer-template": "off",
232+
"require-yield": "error",
233+
"template-curly-spacing": ["error", "never"],
234+
"yield-star-spacing": ["error", "after"]
235+
}
236+
}

.jshintrc

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

README.md

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Chai Assertions for Promises
77

8-
**Chai as Promised** extends [Chai][chai] with a fluent language for asserting facts about [promises][presentation].
8+
**Chai as Promised** extends [Chai](http://chaijs.com/) with a fluent language for asserting facts about [promises](http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript).
99

1010
Instead of manually wiring up your expectations to a promise's fulfilled and rejected handlers:
1111

@@ -90,7 +90,7 @@ return assert.isRejected(promise, /error message matcher/, "optional message");
9090

9191
### Progress Callbacks
9292

93-
Chai as Promised does not have any intrinsic support for testing promise progress callbacks. The properties you would want to test are probably much better suited to a library like [Sinon.JS][sinon], perhaps in conjunction with [Sinon–Chai][sinon-chai]:
93+
Chai as Promised does not have any intrinsic support for testing promise progress callbacks. The properties you would want to test are probably much better suited to a library like [Sinon.JS](http://sinonjs.org/), perhaps in conjunction with [Sinon–Chai](https://github.com/domenic/sinon-chai):
9494

9595
```javascript
9696
var progressSpy = sinon.spy();
@@ -144,15 +144,15 @@ Promise.resolve(2).should.eventually.be.within(Promise.resolve(1), Promise.resol
144144

145145
### Compatibility
146146

147-
Chai as Promised is compatible with all promises following the [Promises/A+ specification][spec].
147+
Chai as Promised is compatible with all promises following the [Promises/A+ specification](http://promisesaplus.com/).
148148

149-
Notably, jQuery's promises were not up to spec before jQuery 3.0, and Chai as Promised will not work with them. In particular, Chai as Promised makes extensive use of the standard [transformation behavior][] of `then`, which jQuery<3.0 does not support.
149+
Notably, jQuery's promises were not up to spec before jQuery 3.0, and Chai as Promised will not work with them. In particular, Chai as Promised makes extensive use of the standard [transformation behavior](http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/#toc_2) of `then`, which jQuery<3.0 does not support.
150150

151151
Angular promises have a special digest cycle for their processing, and [need extra setup code to work with Chai as Promised](http://stackoverflow.com/a/37374041/3191).
152152

153153
### Working with Non-Promise–Friendly Test Runners
154154

155-
Some test runners (e.g. Jasmine, QUnit, or tap/tape) do not have the ability to use the returned promise to signal asynchronous test completion. If possible, I'd recommend switching to ones that do, such as [Mocha][mocha-promises], [Buster][buster-promises], or [blue-tape][]. But if that's not an option, Chai as Promised still has you covered. As long as your test framework takes a callback indicating when the asynchronous test run is over, Chai as Promised can adapt to that situation with its `notify` method, like so:
155+
Some test runners (e.g. Jasmine, QUnit, or tap/tape) do not have the ability to use the returned promise to signal asynchronous test completion. If possible, I'd recommend switching to ones that do, such as [Mocha](http://mochajs.org/#asynchronous-code), [Buster](http://docs.busterjs.org/en/latest/modules/buster-test/spec/#returning-a-promise), or [blue-tape](https://github.com/spion/blue-tape). But if that's not an option, Chai as Promised still has you covered. As long as your test framework takes a callback indicating when the asynchronous test run is over, Chai as Promised can adapt to that situation with its `notify` method, like so:
156156

157157
```javascript
158158
it("should be fulfilled", function (done) {
@@ -216,32 +216,16 @@ chai.should();
216216
// according to your preference of assertion style
217217
```
218218

219-
You can of course put this code in a common test fixture file; for an example using [Mocha][], see [the Chai as Promised tests themselves][fixturedemo].
219+
You can of course put this code in a common test fixture file; for an example using [Mocha](http://mochajs.org), see [the Chai as Promised tests themselves](https://github.com/domenic/chai-as-promised/tree/master/test/).
220220

221221
### In the Browser
222222

223-
To use Chai as Promised in environments that don't support Node.js-like CommonJS modules, you'll need to use a bundling tool like [browserify][].
223+
To use Chai as Promised in environments that don't support Node.js-like CommonJS modules, you'll need to use a bundling tool like [browserify](http://browserify.org/). See also the note below about browser compatibility.
224224

225225
### Karma
226226

227-
If you're using [Karma][], check out the accompanying [karma-chai-as-promised][] plugin.
228-
229-
### Browser Compatibility
230-
231-
Chai as Promised is only compatible with modern browsers (IE ≥9, Safari ≥6, no PhantomJS).
232-
233-
[presentation]: http://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript
234-
[chai]: http://chaijs.com/
235-
[Mocha-promises]: http://mochajs.org/#asynchronous-code
236-
[Buster-promises]: http://docs.busterjs.org/en/latest/modules/buster-test/spec/#returning-a-promise
237-
[blue-tape]: https://github.com/spion/blue-tape
238-
[spec]: http://promisesaplus.com/
239-
[transformation behavior]: http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/#toc_2
240-
[Mocha]: http://mochajs.org
241-
[fixturedemo]: https://github.com/domenic/chai-as-promised/tree/master/test/
242-
[amd]: https://github.com/amdjs/amdjs-api/wiki/AMD
243-
[sinon]: http://sinonjs.org/
244-
[sinon-chai]: https://github.com/domenic/sinon-chai
245-
[Karma]: https://karma-runner.github.io/
246-
[karma-chai-as-promised]: https://github.com/vlkosinov/karma-chai-as-promised
247-
[browserify]: http://browserify.org/
227+
If you're using [Karma](https://karma-runner.github.io/), check out the accompanying [karma-chai-as-promised](https://github.com/vlkosinov/karma-chai-as-promised) plugin.
228+
229+
### Browser/Node Compatibility
230+
231+
Chai as Promised requires Node v4+ or a browser with equivalent support for modern JavaScript syntax. If your browser doesn't support modern JavaScript syntax, you'll need to transpile it down using a tool like [Babel](http://babeljs.io/).

0 commit comments

Comments
 (0)