Skip to content

Commit dd36786

Browse files
authored
Merge pull request #5 from mgol/get-error-hook
Define jQuery.Deferred.getErrorHook
2 parents 4945f3c + 23f305c commit dd36786

13 files changed

+1965
-9885
lines changed

.eslintrc

-5
This file was deleted.

.eslintrc-browser.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"root": true,
3+
4+
"extends": "jquery",
5+
6+
"reportUnusedDisableDirectives": true,
7+
8+
"parserOptions": {
9+
"ecmaVersion": 5
10+
},
11+
12+
// The browser env is not enabled on purpose so that code takes
13+
// all browser-only globals from window instead of assuming
14+
// they're available as globals. This makes it possible to use
15+
// jQuery with tools like jsdom which provide a custom window
16+
// implementation.
17+
"env": {},
18+
19+
"globals": {
20+
"window": true
21+
},
22+
23+
"rules": {
24+
"one-var": [ "error", { "var": "always" } ],
25+
"strict": [ "error", "function" ]
26+
}
27+
}

.eslintrc-node.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"root": true,
3+
4+
"extends": "jquery",
5+
6+
"reportUnusedDisableDirectives": true,
7+
8+
"parserOptions": {
9+
"ecmaVersion": 2022
10+
},
11+
12+
"env": {
13+
"es6": true,
14+
"node": true
15+
},
16+
17+
"globals": {
18+
"globalThis": false
19+
},
20+
21+
"rules": {
22+
"strict": [ "error", "global" ]
23+
}
24+
}

.eslintrc.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"root": true,
3+
4+
"overrides": [
5+
{
6+
"files": "src/**/*.js",
7+
"extends": "./.eslintrc-browser.json",
8+
"globals": {
9+
"define": false,
10+
"module": false,
11+
"require": false,
12+
"jQuery": false
13+
}
14+
},
15+
16+
{
17+
"files": "test/node-setup.js",
18+
"extends": "./.eslintrc-node.json"
19+
},
20+
21+
{
22+
"files": "test/test.js",
23+
"extends": "./.eslintrc-browser.json",
24+
"env": {
25+
"browser": false,
26+
"node": false
27+
},
28+
"globals": {
29+
"globalThis": false,
30+
"QUnit": false,
31+
"jQuery": false
32+
},
33+
"rules": {
34+
"strict": [ "error", "global" ]
35+
}
36+
}
37+
]
38+
}

.github/workflows/node.js.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read # to fetch code (actions/checkout)
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Use Node.js ${{ matrix.NODE_VERSION }}
18+
uses: actions/setup-node@v3.6.0
19+
with:
20+
node-version: 18.x
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Run tests
26+
run: npm test

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# jquery-deferred-reporter
22

3-
This jQuery plugin extends the `jQuery.Deferred` features added in version 3.0 to include a stack trace whenever a Deferred throws an exception. This makes it easier to find programming errors that occur inside Deferreds.
3+
This jQuery plugin extends the `jQuery.Deferred` features added in version 3.0 to include an error captured before the async barrier whenever a Deferred throws an exception. This makes it easier to find programming errors that occur inside Deferreds.
44

55
## Why does this plugin exist?
66

@@ -10,6 +10,4 @@ The native `Promise` object as implemented in the browser tracks Promise rejecti
1010

1111
## Why not just put this in jQuery?
1212

13-
Since it has to save the stack trace regardless of whether an exception will happen or not, adding this plugin makes `jQuery.Deferred` [significantly slower](https://jsfiddle.net/h20r0e6z/5/), by roughly a factor of two.
14-
15-
13+
Since it has to save the error regardless of whether an exception will happen or not, adding this plugin makes `jQuery.Deferred` [significantly slower](https://jsfiddle.net/h20r0e6z/5/), by roughly a factor of two.

0 commit comments

Comments
 (0)