Skip to content

Commit f3d12e5

Browse files
committed
Add GitHub Actions testing, JSHint -> ESLint, rewrite tests in ESM
Also: * switch to Node 20 * update dependencies
1 parent 71ccc63 commit f3d12e5

File tree

10 files changed

+1717
-793
lines changed

10 files changed

+1717
-793
lines changed

.github/workflows/node.js.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Node
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore: ["dependabot/**"]
7+
8+
permissions:
9+
contents: read # to fetch code (actions/checkout)
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ubuntu-latest
14+
name: ${{ matrix.NPM_SCRIPT }} - ${{ matrix.NAME }} (${{ matrix.NODE_VERSION }})
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
NAME: ["Node"]
19+
NODE_VERSION: [20.x]
20+
NPM_SCRIPT: ["test"]
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24+
25+
- name: Use Node.js ${{ matrix.NODE_VERSION }}
26+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
27+
with:
28+
node-version: ${{ matrix.NODE_VERSION }}
29+
30+
- name: Cache
31+
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
32+
with:
33+
path: ~/.npm
34+
key: ${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-${{ hashFiles('**/package-lock.json') }}
35+
restore-keys: |
36+
${{ runner.os }}-node-${{ matrix.NODE_VERSION }}-npm-lock-
37+
38+
- name: Install dependencies
39+
run: npm install
40+
41+
- name: Run tests
42+
run: npm test

.jshintrc

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

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10
1+
20

eslint.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import jqueryConfig from "eslint-config-jquery";
2+
import globals from "globals";
3+
4+
export default [
5+
{
6+
ignores: [
7+
"test/fixtures/**"
8+
]
9+
},
10+
11+
{
12+
languageOptions: {
13+
globals: {
14+
...globals.node
15+
}
16+
},
17+
rules: {
18+
...jqueryConfig.rules,
19+
strict: [ "error", "global" ],
20+
21+
// Too many errors
22+
"max-len": "off"
23+
}
24+
},
25+
26+
{
27+
files: [
28+
"test/*.js"
29+
],
30+
languageOptions: {
31+
globals: {
32+
...globals.node,
33+
...globals.mocha
34+
}
35+
},
36+
rules: {
37+
...jqueryConfig.rules,
38+
39+
// Chai `expect` API violates this rule
40+
"no-unused-expressions": "off",
41+
42+
// Too many errors
43+
"max-len": "off"
44+
}
45+
}
46+
];

lib/cache.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ caches = [];
55

66
cacheCron = function() {
77
var currentTime = Date.now();
8-
caches.forEach(function( cache ) {
8+
caches.forEach( function( cache ) {
99
var count = {
1010
cached: 0,
1111
deleted: 0
1212
};
1313

14-
cache.each(function( value, key ) {
14+
cache.each( function( _value, key ) {
1515
count.cached++;
1616
if ( cache.expires[ key ] < currentTime ) {
1717
cache.destroy( key );
1818
count.deleted++;
1919
}
20-
});
21-
});
20+
} );
21+
} );
2222
cacheCronTimeout = setTimeout( cacheCron, cacheExpiresTime );
2323
};
2424

lib/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

0 commit comments

Comments
 (0)