Skip to content

Commit

Permalink
Merge pull request #334 from benjamine/ci-build-test-lint
Browse files Browse the repository at this point in the history
Update devDependencies
  • Loading branch information
Methuselah96 authored Aug 20, 2023
2 parents 135085c + 2389bd0 commit a27de95
Show file tree
Hide file tree
Showing 29 changed files with 6,701 additions and 9,805 deletions.
17 changes: 2 additions & 15 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
{
"presets": [
"stage-0",
"stage-1",
"stage-2",
[
"env",
{
"modules": false,
"targets": {
"node": "4.8",
"browsers": ["last 2 versions"],
"ie": 8
}
}
]
["@babel/preset-env", { "targets": "defaults" }]
],
"plugins": ["transform-object-rest-spread"]
"plugins": ["@babel/plugin-proposal-export-default-from"]
}
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"extends": ["standard"],
"plugins": ["standard"],
"rules": {
"semi": [2, "always"],
"space-before-function-paren": [2, "never"],
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Use Node.js 8.17.0
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: 8.17.0
node-version: 'lts/*'
cache: 'npm'
- run: npm ci
- run: npm run build
- run: npm run build-dist
- run: npm run test
- run: npm run lint
3 changes: 3 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
spec: ['build/jsondiffpatch.cjs.test.js']
};
6 changes: 3 additions & 3 deletions docs/demo/consoledemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const data = {
],
};

let left = JSON.parse(JSON.stringify(data), jsondiffpatch.dateReviver);
const left = JSON.parse(JSON.stringify(data), jsondiffpatch.dateReviver);

data.summary = data.summary
.replace('Brazil', 'Brasil')
Expand All @@ -156,6 +156,6 @@ delete data.surface;
data.spanishName = 'Sudamérica';
data.demographics.population += 2342;

let right = data;
let delta = instance.diff(left, right);
const right = data;
const delta = instance.diff(left, right);
jsondiffpatch.console.log(delta);
61 changes: 31 additions & 30 deletions docs/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
],
};

let json = [JSON.stringify(data, null, 2)];
const json = [JSON.stringify(data, null, 2)];

data.summary = data.summary
.replace('Brazil', 'Brasil')
Expand Down Expand Up @@ -189,9 +189,9 @@
el.className = el.className.replace(
new RegExp(
'(^|\\b)' + className.split(' ').join('|') + '(\\b|$)',
'gi'
'gi',
),
' '
' ',
);
}
},
Expand Down Expand Up @@ -236,7 +236,7 @@
try {
data = JSON.parse(this.responseText, jsondiffpatch.dateReviver);
} catch (parseError) {
// eslint-disable-next-line standard/no-callback-literal
// eslint-disable-next-line n/no-callback-literal
return callback('parse error: ' + parseError);
}
if (this.status >= 200 && this.status < 400) {
Expand All @@ -250,9 +250,9 @@
request = null;
},
runScriptTags: function(el) {
let scripts = el.querySelectorAll('script');
const scripts = el.querySelectorAll('script');
for (let i = 0; i < scripts.length; i++) {
let s = scripts[i];
const s = scripts[i];
// eslint-disable-next-line no-eval
eval(s.innerHTML);
}
Expand Down Expand Up @@ -335,7 +335,7 @@
this.editor = CodeMirror.fromTextArea(this.element, {
mode: 'javascript',
json: true,
readOnly: readOnly,
readOnly,
});
if (!readOnly) {
this.editor.on('change', compare);
Expand Down Expand Up @@ -391,7 +391,7 @@
case 'visual':
visualdiff.innerHTML = jsondiffpatch.formatters.html.format(
delta,
left
left,
);
if (!document.getElementById('showunchanged').checked) {
jsondiffpatch.formatters.html.hideUnchanged();
Expand All @@ -400,7 +400,7 @@
break;
case 'annotated':
annotateddiff.innerHTML = jsondiffpatch.formatters.annotated.format(
delta
delta,
);
break;
case 'json':
Expand Down Expand Up @@ -458,21 +458,21 @@
dom.on(
document.getElementById('show-delta-type-visual'),
'click',
showSelectedDeltaType
showSelectedDeltaType,
);
dom.on(
document.getElementById('show-delta-type-annotated'),
'click',
showSelectedDeltaType
showSelectedDeltaType,
);
dom.on(
document.getElementById('show-delta-type-json'),
'click',
showSelectedDeltaType
showSelectedDeltaType,
);

dom.on(document.getElementById('swap'), 'click', function() {
let leftValue = areas.left.getValue();
const leftValue = areas.left.getValue();
areas.left.setValue(areas.right.getValue());
areas.right.setValue(leftValue);
compare();
Expand All @@ -488,7 +488,7 @@
jsondiffpatch.formatters.html.showUnchanged(
document.getElementById('showunchanged').checked,
null,
800
800,
);
});

Expand All @@ -514,11 +514,11 @@

dom.text(
document.getElementById('json-panel-left').querySelector('h2'),
(data.left && data.left.name) || 'left.json'
(data.left && data.left.name) || 'left.json',
);
dom.text(
document.getElementById('json-panel-right').querySelector('h2'),
(data.right && data.right.name) || 'right.json'
(data.right && data.right.name) || 'right.json',
);

document
Expand All @@ -539,21 +539,21 @@
load.gist = function(id) {
dom.getJson('https://api.github.com/gists/' + id, function(error, data) {
if (error) {
let message = error + (data && data.message ? data.message : '');
const message = error + (data && data.message ? data.message : '');
load.data({
error: message,
});
return;
}
let filenames = [];
for (let filename in data.files) {
let file = data.files[filename];
const filenames = [];
for (const filename in data.files) {
const file = data.files[filename];
if (file.language === 'JSON') {
filenames.push(filename);
}
}
filenames.sort();
let files = [data.files[filenames[0]], data.files[filenames[1]]];
const files = [data.files[filenames[0]], data.files[filenames[1]]];
/* jshint camelcase: false */
load.data({
url: data.html_url,
Expand All @@ -577,7 +577,7 @@
const rightValue = decodeURIComponent(rightValueArg);
const urlmatch = /https?:\/\/.*\/([^/]+\.json)(?:[?#].*)?/;
const dataLoaded = {
description: description,
description,
left: {},
right: {},
};
Expand Down Expand Up @@ -633,7 +633,7 @@
gist: /^(?:https?:\/\/)?(?:gist\.github\.com\/)?(?:[\w0-9\-a-f]+\/)?([0-9a-f]+)$/i,
leftright: /^(?:desc=(.*)?&)?left=(.*)&right=(.*)&?$/i,
};
for (let loader in matchers) {
for (const loader in matchers) {
const match = matchers[loader].exec(key);
if (match) {
return load[loader].apply(load, match.slice(1));
Expand All @@ -658,7 +658,7 @@
dom.on(document.getElementById('examples'), 'change', function() {
const example = trim(this.value);
switch (example) {
case 'text':
case 'text': {
const exampleJson = getExampleJson();
load.data({
left: {
Expand All @@ -671,18 +671,19 @@
},
});
break;
}
case 'gist':
document.location = '?benjamine/9188826';
break;
case 'moving':
document.location =
'?desc=moving%20around&left=' +
encodeURIComponent(
JSON.stringify([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
JSON.stringify([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
) +
'&right=' +
encodeURIComponent(
JSON.stringify([10, 0, 1, 7, 2, 4, 5, 6, 88, 9, 3])
JSON.stringify([10, 0, 1, 7, 2, 4, 5, 6, 88, 9, 3]),
);
break;
case 'query':
Expand All @@ -693,26 +694,26 @@
JSON.stringify({
"don't": 'abuse',
with: ['large', 'urls'],
})
}),
) +
'&right=' +
encodeURIComponent(
JSON.stringify({
"don't": 'use',
with: ['>', 2, 'KB urls'],
})
}),
);
break;
case 'urls':
document.location =
'?desc=http%20raw%20file%20urls&left=' +
encodeURIComponent(
'https://rawgithub.com/benjamine/JsonDiffPatch/' +
'c83e942971c627f61ef874df3cfdd50a95f1c5a2/package.json'
'c83e942971c627f61ef874df3cfdd50a95f1c5a2/package.json',
) +
'&right=' +
encodeURIComponent(
'https://rawgithub.com/benjamine/JsonDiffPatch/master/package.json'
'https://rawgithub.com/benjamine/JsonDiffPatch/master/package.json',
);
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions docs/demo/numeric-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Plugin a new diff filter
},
{
population: 403,
}
},
);
assertSame(delta, [0, 3, NUMERIC_DIFFERENCE]);

Expand All @@ -64,7 +64,7 @@ Plugin a new diff filter
{
population: 400,
},
delta
delta,
);
assertSame(right, {
population: 403,
Expand Down
Loading

0 comments on commit a27de95

Please sign in to comment.