Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit ff80c4f

Browse files
authored
Remove circle ci (#21)
* removes circle, adds github actions * bumps and fix eslint errors
1 parent 0b8ce12 commit ff80c4f

6 files changed

Lines changed: 141 additions & 74 deletions

File tree

.circleci/config.yml

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

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["*"]
8+
9+
workflow_dispatch:
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [18, 20]
17+
mongodb-version: [6.0, 7.0]
18+
19+
steps:
20+
- name: Git checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Start MongoDB
29+
uses: supercharge/mongodb-github-action@1.11.0
30+
with:
31+
mongodb-version: ${{ matrix.mongodb-version }}
32+
33+
- run: npm install
34+
35+
- run: npm test
36+
env:
37+
CI: true

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![CircleCI](https://circleci.com/gh/apostrophecms/launder/tree/master.svg?style=svg)](https://circleci.com/gh/apostrophecms/launder/tree/master)
2-
31
<a href="https://apostrophecms.com/"><img src="https://raw.github.com/apostrophecms/launder/master/logos/logo-box-madefor.png" align="right" /></a>
42

53
A sanitization module for the people. Built for use in the [ApostropheCMS](https://apostrophecms.com), useful for many other things.

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module.exports = function(options) {
164164
choice = choices.find(function(choice) {
165165
if ((choice.value === null) || (choice.value === undefined)) {
166166
// Don't crash on invalid choices
167-
return;
167+
return false;
168168
}
169169
return choice.value.toString() === s;
170170
});
@@ -176,7 +176,7 @@ module.exports = function(options) {
176176
choice = choices.find(function(choice) {
177177
if ((choice === null) || (choice === undefined)) {
178178
// Don't crash on invalid choices
179-
return;
179+
return false;
180180
}
181181
return choice.toString() === s;
182182
});
@@ -390,8 +390,9 @@ module.exports = function(options) {
390390
};
391391

392392
// This is likely not relevent to you unless you're using Apostrophe
393-
// Given a date object, return a date string in Apostrophe's preferred sortable, comparable, JSON-able format,
394-
// which is YYYY-MM-DD. If `date` is undefined the current date is used.
393+
// Given a date object, return a date string in Apostrophe's preferred sortable,
394+
// comparable, JSON-able format, which is YYYY-MM-DD. If `date` is undefined
395+
// the current date is used.
395396
self.formatDate = function(date) {
396397
return dayjs(date).format('YYYY-MM-DD');
397398
};

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"description": "A sanitize module for the people. Built for ApostropheCMS.",
55
"main": "index.js",
66
"scripts": {
7-
"test": "npx eslint . && mocha test/test.js"
7+
"lint": "npm run eslint",
8+
"eslint": "eslint .",
9+
"test": "npm run lint && npm run mocha",
10+
"mocha": "mocha"
811
},
912
"repository": {
1013
"type": "git",
@@ -21,13 +24,7 @@
2124
},
2225
"homepage": "https://github.com/apostrophecms/launder",
2326
"devDependencies": {
24-
"eslint": "^6.5.1",
25-
"eslint-config-apostrophe": "^2.0.2",
26-
"eslint-config-standard": "^11.0.0",
27-
"eslint-plugin-import": "^2.18.2",
28-
"eslint-plugin-node": "^6.0.1",
29-
"eslint-plugin-promise": "^3.8.0",
30-
"eslint-plugin-standard": "^3.1.0",
27+
"eslint-config-apostrophe": "^5.0.0",
3128
"mocha": "^5.0.0"
3229
},
3330
"dependencies": {

test/test.js

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,30 @@ describe('launder', function() {
115115
});
116116

117117
it('should convert non-string/non-number to an empty string', function() {
118-
assert(launder.string({an: 'object'}) === '');
119-
assert(launder.string(function() { return 'still not a string'; }) === '');
118+
assert(launder.string({ an: 'object' }) === '');
119+
assert(launder.string(function() {
120+
return 'still not a string';
121+
}) === '');
120122
});
121123

122124
it('should use a default for non-strings', function() {
123-
assert(launder.string({an: 'object'}, 'default') === 'default');
125+
assert(launder.string({ an: 'object' }, 'default') === 'default');
124126
});
125127
});
126128

127129
describe('strings', function() {
128130
it('should do good stuff to an array of strings', function() {
129-
const s = launder.strings([' testing ', 123]);
131+
const s = launder.strings([ ' testing ', 123 ]);
130132
assert(s[0] === 'testing');
131133
assert(s[1] === '123');
132134
});
133135

134136
it('should return an empty array if we pass in something that is not an array', function() {
135-
const s = launder.strings({an: 'object', is: 'not', typeof: 'array'});
137+
const s = launder.strings({
138+
an: 'object',
139+
is: 'not',
140+
typeof: 'array'
141+
});
136142
assert(Array.isArray(s));
137143
assert(s.length === 0);
138144
});
@@ -248,14 +254,26 @@ describe('launder', function() {
248254

249255
describe('select', function() {
250256
it('should do nothing to a good choice from an array', function() {
251-
assert(launder.select('n', ['p', 'u', 'n', 'k']) === 'n');
257+
assert(launder.select('n', [ 'p', 'u', 'n', 'k' ]) === 'n');
252258
});
253259
it('should do nothing to a good choice from an object', function() {
254260
const s = launder.select('n', [
255-
{ name: 'Probably amazing', value: 'p' },
256-
{ name: 'Utterly incredible', value: 'u' },
257-
{ name: 'Never gonna give you up', value: 'n' },
258-
{ name: 'Kind hearted', value: 'k' }
261+
{
262+
name: 'Probably amazing',
263+
value: 'p'
264+
},
265+
{
266+
name: 'Utterly incredible',
267+
value: 'u'
268+
},
269+
{
270+
name: 'Never gonna give you up',
271+
value: 'n'
272+
},
273+
{
274+
name: 'Kind hearted',
275+
value: 'k'
276+
}
259277
]);
260278
assert(s === 'n');
261279
});
@@ -266,36 +284,63 @@ describe('launder', function() {
266284
assert(launder.select('hi', [], 'bye') === 'bye');
267285
});
268286
it('should return the default if the choice is not found in an array', function() {
269-
assert(launder.select('hi', ['not', 'in', 'here'], 'bye') === 'bye');
287+
assert(launder.select('hi', [ 'not', 'in', 'here' ], 'bye') === 'bye');
270288
});
271289
it('should not crash if a null choice is present', function() {
272-
assert(launder.select('yes', ['not', null, 'yes']) === 'yes');
290+
assert(launder.select('yes', [ 'not', null, 'yes' ]) === 'yes');
273291
});
274292
it('should not crash if an undefined choice is present', function() {
275-
assert(launder.select('yes', ['not', undefined, 'yes']) === 'yes');
293+
assert(launder.select('yes', [ 'not', undefined, 'yes' ]) === 'yes');
276294
});
277295
it('should not crash if a null choice is present, with labels', function() {
278-
assert(launder.select('yes', [{ value: 'not', label: 'Not' }, { value: null, label: 'broken' }, { value: 'yes', label: 'Yes' }]) === 'yes');
296+
assert(launder.select('yes', [ {
297+
value: 'not',
298+
label: 'Not'
299+
}, {
300+
value: null,
301+
label: 'broken'
302+
}, {
303+
value: 'yes',
304+
label: 'Yes'
305+
} ]) === 'yes');
279306
});
280307
it('should not crash if an undefined choice is present, with labels', function() {
281-
assert(launder.select('yes', [{ value: 'not', label: 'Not' }, { value: undefined, label: 'broken' }, { value: 'yes', label: 'Yes' }]) === 'yes');
308+
assert(launder.select('yes', [ {
309+
value: 'not',
310+
label: 'Not'
311+
}, {
312+
value: undefined,
313+
label: 'broken'
314+
}, {
315+
value: 'yes',
316+
label: 'Yes'
317+
} ]) === 'yes');
282318
});
283319
it('should return the default if the choice is not found in an object', function() {
284320
const s = launder.select('hi', [
285-
{ name: 'Not something', value: 'not' },
286-
{ name: 'Inside', value: 'in' },
287-
{ name: 'Here anymore', value: 'here' }
321+
{
322+
name: 'Not something',
323+
value: 'not'
324+
},
325+
{
326+
name: 'Inside',
327+
value: 'in'
328+
},
329+
{
330+
name: 'Here anymore',
331+
value: 'here'
332+
}
288333
], 'bye');
289334
assert(s === 'bye');
290335
});
291336
it('should return the default if the choice is not found in an array', function() {
292-
assert(launder.select('hi', ['not', 'in', 'here'], 'bye') === 'bye');
337+
assert(launder.select('hi', [ 'not', 'in', 'here' ], 'bye') === 'bye');
293338
});
294339
it('should match a string input matching the string representation of a choice that is a number, and return the number, not the string', function() {
295-
assert(launder.select('5', [1, 3, 5], 1) === 5);
340+
assert(launder.select('5', [ 1, 3, 5 ], 1) === 5);
296341
});
297342
it('should match a number matching a choice that is a number, and return the number, not a stringification of it', function() {
298-
assert(launder.select(5, [1, 3, 5], 1) === 5);
343+
assert(launder.select(5, [ 1, 3, 5 ], 1) === 5);
299344
});
300345
});
301346

@@ -378,9 +423,9 @@ describe('launder', function() {
378423
describe('addBooleanFilterToCriteria', function() {
379424
const name = 'published';
380425
const criteria = {};
381-
const optionsTrue = { 'published': true };
382-
const optionsFalse = { 'published': false };
383-
const optionsEmpty = { 'published': '' };
426+
const optionsTrue = { published: true };
427+
const optionsFalse = { published: false };
428+
const optionsEmpty = { published: '' };
384429

385430
it('should not change criteria if option is `any`', function() {
386431
launder.addBooleanFilterToCriteria('any', name, criteria);
@@ -400,7 +445,7 @@ describe('launder', function() {
400445
assert(criteria[name] === true);
401446
const criteria2 = {};
402447
launder.addBooleanFilterToCriteria(optionsFalse, name, criteria2);
403-
assert(criteria2[name]['$ne'] === true);
448+
assert(criteria2[name].$ne === true);
404449
});
405450
it('should be able to use a boolean string `true` for options', function() {
406451
const criteria = {};
@@ -418,22 +463,22 @@ describe('launder', function() {
418463
assert(criteria[name] === true);
419464
criteria = {};
420465
launder.addBooleanFilterToCriteria(false, name, criteria);
421-
assert(criteria[name]['$ne'] === true);
466+
assert(criteria[name].$ne === true);
422467
});
423468
it('should treat empty string as false', function() {
424469
const criteria = {};
425470
launder.addBooleanFilterToCriteria('', name, criteria);
426-
assert(criteria[name]['$ne'] === true);
471+
assert(criteria[name].$ne === true);
427472
});
428473
it('should treat empty string in an object as false', function() {
429474
const criteria = {};
430475
launder.addBooleanFilterToCriteria(optionsEmpty, name, criteria);
431-
assert(criteria[name]['$ne'] === true);
476+
assert(criteria[name].$ne === true);
432477
});
433478
it('should take a default if `options` or `options[name]` is undefined', function() {
434479
const criteria = {};
435480
launder.addBooleanFilterToCriteria({}, name, criteria, false);
436-
assert(criteria[name]['$ne'] === true);
481+
assert(criteria[name].$ne === true);
437482
});
438483
});
439484

@@ -538,10 +583,10 @@ describe('launder', function() {
538583
});
539584

540585
describe('tags', function() {
541-
const goodTags = ['one', 'two', 'three'];
542-
const spaceyTags = [' One', 'TWO', ' three '];
543-
const numberTags = [12, 34];
544-
const troubleTags = ['one', 2, {an: 'object'}, null, 'three'];
586+
const goodTags = [ 'one', 'two', 'three' ];
587+
const spaceyTags = [ ' One', 'TWO', ' three ' ];
588+
const numberTags = [ 12, 34 ];
589+
const troubleTags = [ 'one', 2, { an: 'object' }, null, 'three' ];
545590

546591
it('should do nothing to a good array of tags', function() {
547592
const t = launder.tags(goodTags);
@@ -558,7 +603,11 @@ describe('launder', function() {
558603
assert(t[2] === 'three');
559604
});
560605
it('should return an empty array if you pass in something that is not an array', function() {
561-
const t = launder.tags({an: 'object', is: 'not', typeof: 'array'});
606+
const t = launder.tags({
607+
an: 'object',
608+
is: 'not',
609+
typeof: 'array'
610+
});
562611
assert(Array.isArray(t));
563612
assert(t.length === 0);
564613
});
@@ -576,14 +625,18 @@ describe('launder', function() {
576625
assert(t[2] === 'three');
577626
});
578627
it('should take a filter function', function() {
579-
const t = launder.tags(numberTags, function(tag) { return tag + '0'; });
628+
const t = launder.tags(numberTags, function(tag) {
629+
return tag + '0';
630+
});
580631
assert(t.length === 2);
581632
assert(t[0] === '120');
582633
assert(t[1] === '340');
583634
});
584635
it('should allow a different filter function to be set during initiation', function() {
585636
const launder = require('../index.js')({
586-
filterTag: function(tag) { return tag + '0'; }
637+
filterTag: function(tag) {
638+
return tag + '0';
639+
}
587640
});
588641
const t = launder.tags(numberTags);
589642
assert(t.length === 2);
@@ -622,7 +675,11 @@ describe('launder', function() {
622675
assert(i[2] === '1003');
623676
});
624677
it('should return an empty array if you pass in something that is not an array', function() {
625-
const i = launder.ids({ an: 'object', is: 'not', typeof: 'array' });
678+
const i = launder.ids({
679+
an: 'object',
680+
is: 'not',
681+
typeof: 'array'
682+
});
626683
assert(Array.isArray(i));
627684
assert(i.length === 0);
628685
});

0 commit comments

Comments
 (0)