Skip to content

Commit

Permalink
fix: changed jsonlint to @prantlf/jsonlint
Browse files Browse the repository at this point in the history
  • Loading branch information
lohxt1 committed Oct 9, 2024
1 parent c0dc329 commit ce56af2
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 91 deletions.
166 changes: 86 additions & 80 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bruno-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"@prantlf/jsonlint": "^16.0.0",
"@reduxjs/toolkit": "^1.8.0",
"@tabler/icons": "^1.46.0",
"@tippyjs/react": "^4.2.6",
Expand Down Expand Up @@ -44,7 +45,6 @@
"jshint": "^2.13.6",
"json5": "^2.2.3",
"jsonc-parser": "^3.2.1",
"jsonlint": "^1.6.3",
"jsonpath-plus": "^7.2.0",
"know-your-http-well": "^0.5.0",
"lodash": "^4.17.21",
Expand Down
24 changes: 14 additions & 10 deletions packages/bruno-app/src/components/CodeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isEqual, escapeRegExp } from 'lodash';
import { getEnvironmentVariables } from 'utils/collections';
import { defineCodeMirrorBrunoVariablesMode } from 'utils/common/codemirror';
import StyledWrapper from './StyledWrapper';
import jsonlint from 'jsonlint';
import * as jsonlint from '@prantlf/jsonlint';
import { JSHINT } from 'jshint';
import stripJsonComments from 'strip-json-comments';

Expand Down Expand Up @@ -250,18 +250,22 @@ export default class CodeEditor extends React.Component {
}
return found;
}

let jsonlint = window.jsonlint.parser || window.jsonlint;
jsonlint.parseError = function (str, hash) {
let loc = hash.loc;
found.push({
from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
message: str
});
};
try {
jsonlint.parse(stripJsonComments(text.replace(/(?<!"[^":{]*){{[^}]*}}(?![^"},]*")/g, '1')));
} catch (e) {}
} catch (error) {
const { message, location } = error;
const line = location?.start?.line;
const column = location?.start?.column;
if (line && column) {
found.push({
from: CodeMirror.Pos(line - 1, column),
to: CodeMirror.Pos(line - 1, column),
message
});
}
}
return found;
});
if (editor) {
Expand Down

0 comments on commit ce56af2

Please sign in to comment.