Skip to content

Commit

Permalink
fix: require node v10 and later (#998)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
node v9 and older is no longer supported. They were soft dropped a long time ago, as the oldest version our node testing suite can run on is v10. But it's now being hard-dropped and the babel generated output will no longer target `v0.10.16`. Only node versions that receive security patches will be supported moving forward.
  • Loading branch information
stipsan authored Oct 21, 2020
1 parent 1d91486 commit 2da1aa6
Show file tree
Hide file tree
Showing 192 changed files with 853 additions and 735 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:10
- image: circleci/node:12
# To support coverage reports from forks
environment:
CODECLIMATE_REPO_TOKEN: 688d3234f9bb133fe6efa4dfe74f7a7510f2d9c1dca419875de8257a5f02da45
Expand Down
17 changes: 10 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
"no-plusplus": "off",
"func-names": "off",
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}]
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
needs: [build]
strategy:
matrix:
node_version: [10, 12, 13]
node_version: [10, 12, 14, 15]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,23 @@ on:
name: Test Coveralls

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- uses: actions/checkout@v1

- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: npm install, make test-coverage
run: |
yarn --frozen-lockfile
yarn coverage
- name: npm install, make test-coverage
run: |
yarn --frozen-lockfile
yarn coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
47 changes: 23 additions & 24 deletions .github/workflows/updatecompat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,29 @@ on:

jobs:
format:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{github.head_ref}}
- name: use node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install
- run: node scripts/update-compat
- name: commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add compat.md
git commit -m "docs: update feature compat table"
continue-on-error: true
- name: push changes
uses: ad-m/github-push-action@master
with:
branch: ${{github.head_ref}}
repository: ${{ github.event.pull_request.head.repo.full_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v1
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{github.head_ref}}
- name: use node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install
- run: node scripts/update-compat
- name: commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add compat.md
git commit -m "docs: update feature compat table"
continue-on-error: true
- name: push changes
uses: ad-m/github-push-action@master
with:
branch: ${{github.head_ref}}
repository: ${{ github.event.pull_request.head.repo.full_name }}
github_token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
package.json
package.json
package-lock.json
lib
.nyc_output
coverage
junit
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [['@babel/env', { targets: { node: '0.10.16' } }]],
presets: [['@babel/env', { targets: { node: '10' }, bugfixes: true }]],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"redisjs"
],
"engines": {
"node": ">=0.10.16"
"node": ">=10"
},
"husky": {
"hooks": {
Expand Down
9 changes: 6 additions & 3 deletions scripts/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
"node": true
},
"rules": {
"import/no-extraneous-dependencies": ['error', {
"devDependencies": true
}]
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
}
}
8 changes: 4 additions & 4 deletions scripts/update-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ const blacklist = [
'unlink',
];
const filteredCommands = commands.list.filter(
command => blacklist.indexOf(command) === -1
(command) => blacklist.indexOf(command) === -1
);

let supportedCommands = 0;
let tableRows = `
| redis | ioredis | ioredis-mock |
|-------|:-------:|:------------:|`;
filteredCommands.forEach(command => {
filteredCommands.forEach((command) => {
const redisCol = `[${command}](http://redis.io/commands/${command.toUpperCase()})`;
const ioredisCol = command in redis.prototype ? ':white_check_mark:' : ':x:';
const supportedCommand = command in mockedRedis;
Expand Down Expand Up @@ -68,7 +68,7 @@ fs.writeFile(
path.resolve(__dirname, '..', 'compat.md'),
prettier.format(tableMd, { parser: 'markdown' }),
'utf8',
err => {
(err) => {
if (err) throw err;
}
);
Expand All @@ -86,7 +86,7 @@ fs.readFile(readme, 'utf8', (err, readmeMd) => {
`[![Redis Compatibility: ${percentage}%](https://img.shields.io/badge/redis-${percentage}%25-${color}.svg?style=flat-square)](compat.md)`
),
'utf8',
err2 => {
(err2) => {
if (err2) throw err2;
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function throwIfCommandIsNotAllowed(commandName, RedisMock) {
* Transform non-buffer arguments to strings to simulate real ioredis behavior
* @param {any} arg the argument to transform
*/
const argMapper = arg => {
const argMapper = (arg) => {
if (arg === null || arg === undefined) return '';
return arg instanceof Buffer ? arg : arg.toString();
};
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function command(commandEmulator, commandName, RedisMock) {
const Promise = promiseContainer.get();

return asCallback(
new Promise(resolve =>
new Promise((resolve) =>
resolve(
safelyExecuteCommand(
commandEmulator,
Expand Down
4 changes: 2 additions & 2 deletions src/commands-utils/readable-scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ReadableScan extends Readable {
return;
}
this._callScan()
.then(res => {
.then((res) => {
const [nextCursor, keys] = res;
if (nextCursor === '0') {
this._drained = true;
Expand All @@ -39,6 +39,6 @@ export default class ReadableScan extends Readable {
if (keys.length > 0) this.push(keys);
else this._read();
})
.catch(err => process.nextTick(() => this.emit('error', err)));
.catch((err) => process.nextTick(() => this.emit('error', err)));
}
}
2 changes: 1 addition & 1 deletion src/commands/brpoplpushBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import createBuffer from '../buffer';

export function brpoplpushBuffer(source, destination) {
const valP = brpoplpush.apply(this, [source, destination]);
return valP.then(val => (val ? createBuffer(val) : val));
return valP.then((val) => (val ? createBuffer(val) : val));
}
4 changes: 2 additions & 2 deletions src/commands/defineCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { lua, to_luastring: toLuaString } = fengari;
* ->
* @param fn - a function returning 0 for non-error and != 0 for error
*/
export const defineRedisObject = vm => fn => {
export const defineRedisObject = (vm) => (fn) => {
vm.defineGlobalFunction(fn, 'call');

// define redis object with call method
Expand All @@ -40,7 +40,7 @@ export const defineRedisObject = vm => fn => {
lua.lua_setglobal(vm.L, toLuaString('redis'));
};

const callToRedisCommand = vm =>
const callToRedisCommand = (vm) =>
function callToRedisCommand2() {
const rawArgs = vm.extractArgs();
const returnError = rawArgs[0];
Expand Down
2 changes: 1 addition & 1 deletion src/commands/del.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { emitNotification } from '../keyspace-notifications';

export function del(...keys) {
let deleted = 0;
keys.forEach(key => {
keys.forEach((key) => {
if (this.data.has(key)) {
deleted++;
emitNotification(this, 'g', key, 'del');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/hdel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function hdel(key, ...fields) {
if (!value) {
return 0;
}
const numDeleted = fields.filter(field => {
const numDeleted = fields.filter((field) => {
if ({}.hasOwnProperty.call(value, field)) {
delete value[field];
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/hgetallBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import createBuffer from '../buffer';

export function hgetallBuffer(key) {
const val = hgetall.apply(this, [key]);
Object.keys(val).forEach(keyInObject => {
Object.keys(val).forEach((keyInObject) => {
val[keyInObject] = createBuffer(val[keyInObject]);
});

Expand Down
2 changes: 1 addition & 1 deletion src/commands/hmget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function hmget(key, ...fields) {
const hash = this.data.get(key);
return fields.map(field => {
return fields.map((field) => {
if (!hash || hash[field] === undefined) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/hmgetBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import createBuffer from '../buffer';

export function hmgetBuffer(key, ...fields) {
const val = hmget.apply(this, [key, ...fields]);
return val.map(payload => (payload ? createBuffer(payload) : payload));
return val.map((payload) => (payload ? createBuffer(payload) : payload));
}
2 changes: 1 addition & 1 deletion src/commands/keys.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import minimatch from 'minimatch';

export function keys(globString) {
return this.data.keys().filter(key => minimatch(key, globString));
return this.data.keys().filter((key) => minimatch(key, globString));
}
2 changes: 1 addition & 1 deletion src/commands/mget.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function mget(...keys) {
return keys.map(key => (this.data.has(key) ? this.data.get(key) : null));
return keys.map((key) => (this.data.has(key) ? this.data.get(key) : null));
}
2 changes: 1 addition & 1 deletion src/commands/psubscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '../commands-utils/channel-subscription';

export function psubscribe(...args) {
args.forEach(pattern => {
args.forEach((pattern) => {
if (!this.patternChannels.instanceListeners) {
this.patternChannels.instanceListeners = new Map();
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export function publish(channel, message) {
this.channels.emit(channel, message);
const matchingPatterns = this.patternChannels
.eventNames()
.filter(pattern => minimatch(channel, pattern));
matchingPatterns.forEach(matchingChannel =>
.filter((pattern) => minimatch(channel, pattern));
matchingPatterns.forEach((matchingChannel) =>
this.patternChannels.emit(matchingChannel, message, channel)
);
const numberOfSubscribers =
Expand Down
4 changes: 2 additions & 2 deletions src/commands/punsubscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {

export function punsubscribe(...args) {
if (args.length === 0) {
getSubscribedChannels(this, this.patternChannels).forEach(channel => {
getSubscribedChannels(this, this.patternChannels).forEach((channel) => {
unsubscribeFromChannel(this, channel, this.patternChannels);
});
}
args.forEach(pattern => {
args.forEach((pattern) => {
unsubscribeFromChannel(this, pattern, this.patternChannels);
});
const numberOfSubscribedChannels = getSubscribedChannels(
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sadd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function sadd(key, ...vals) {
}
let added = 0;
const set = this.data.get(key);
vals.forEach(value => {
vals.forEach((value) => {
if (!set.has(value)) {
added++;
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/sdiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ export function sdiff(ours, ...theirs) {
if (this.data.has(ours) && !(this.data.get(ours) instanceof Set)) {
throw new Error(`Key ${ours} does not contain a set`);
}
theirs.forEach(key => {
theirs.forEach((key) => {
if (this.data.has(key) && !(this.data.get(key) instanceof Set)) {
throw new Error(`Key ${key} does not contain a set`);
}
});

const ourSet = this.data.has(ours) ? this.data.get(ours) : new Set();
const theirSets = theirs.map(
key => (this.data.has(key) ? this.data.get(key) : new Set())
const theirSets = theirs.map((key) =>
this.data.has(key) ? this.data.get(key) : new Set()
);
const difference = new Set(
arrayFrom(ourSet).filter(ourValue =>
arrayFrom(ourSet).filter((ourValue) =>
theirSets.reduce(
(isUnique, set) => (set.has(ourValue) ? false : isUnique),
/* isUnique */ true
Expand Down
2 changes: 1 addition & 1 deletion src/commands/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function set(key, value, ...options) {
const nx = options.indexOf('NX') !== -1;
const xx = options.indexOf('XX') !== -1;
const filteredOptions = options.filter(
option => option !== 'NX' && option !== 'XX'
(option) => option !== 'NX' && option !== 'XX'
);

if (nx && xx) throw new Error('ERR syntax error');
Expand Down
Loading

0 comments on commit 2da1aa6

Please sign in to comment.