Format json files in using prettier

This commit is contained in:
Calixte Denizet 2024-01-16 19:40:25 +01:00
parent 51413be5b6
commit 29de9bdce6
8 changed files with 9356 additions and 8558 deletions

11
.prettierignore Normal file
View File

@ -0,0 +1,11 @@
build/
l10n/
docs/
node_modules/
external/bcmaps/
external/builder/fixtures/
external/builder/fixtures_esprima/
external/quickjs/
test/tmp/
test/pdfs/
*~/

View File

@ -11,32 +11,30 @@
}, },
"permissions": [ "permissions": [
"fileBrowserHandler", "fileBrowserHandler",
"webRequest", "webRequestBlocking", "webRequest",
"webRequestBlocking",
"<all_urls>", "<all_urls>",
"tabs", "tabs",
"webNavigation", "webNavigation",
"storage" "storage"
], ],
"content_scripts": [{ "content_scripts": [
"matches": [ {
"http://*/*", "matches": ["http://*/*", "https://*/*", "ftp://*/*", "file://*/*"],
"https://*/*",
"ftp://*/*",
"file://*/*"
],
"run_at": "document_start", "run_at": "document_start",
"all_frames": true, "all_frames": true,
"css": ["contentstyle.css"], "css": ["contentstyle.css"],
"js": ["contentscript.js"] "js": ["contentscript.js"]
}], }
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"file_browser_handlers": [{ "file_browser_handlers": [
{
"id": "open-as-pdf", "id": "open-as-pdf",
"default_title": "Open with PDF Viewer", "default_title": "Open with PDF Viewer",
"file_filters": [ "file_filters": ["filesystem:*.pdf"]
"filesystem:*.pdf" }
] ],
}],
"storage": { "storage": {
"managed_schema": "preferences_schema.json" "managed_schema": "preferences_schema.json"
}, },

View File

@ -5,11 +5,7 @@
"title": "Theme", "title": "Theme",
"description": "The theme to use.\n0 = Use system theme.\n1 = Light theme.\n2 = Dark theme.", "description": "The theme to use.\n0 = Use system theme.\n1 = Light theme.\n2 = Dark theme.",
"type": "integer", "type": "integer",
"enum": [ "enum": [0, 1, 2],
0,
1,
2
],
"default": 2 "default": 2
}, },
"showPreviousViewOnLoad": { "showPreviousViewOnLoad": {
@ -21,11 +17,7 @@
"title": "View position on load", "title": "View position on load",
"description": "The position in the document upon load.\n -1 = Default (uses OpenAction if available, otherwise equal to `viewOnLoad = 0`).\n 0 = The last viewed page/position.\n 1 = The initial page/position.", "description": "The position in the document upon load.\n -1 = Default (uses OpenAction if available, otherwise equal to `viewOnLoad = 0`).\n 0 = The last viewed page/position.\n 1 = The initial page/position.",
"type": "integer", "type": "integer",
"enum": [ "enum": [-1, 0, 1],
-1,
0,
1
],
"default": 0 "default": 0
}, },
"defaultZoomDelay": { "defaultZoomDelay": {
@ -45,13 +37,7 @@
"title": "Sidebar state on load", "title": "Sidebar state on load",
"description": "Controls the state of the sidebar upon load.\n -1 = Default (uses PageMode if available, otherwise the last position if available/enabled).\n 0 = Do not show sidebar.\n 1 = Show thumbnails in sidebar.\n 2 = Show document outline in sidebar.\n 3 = Show attachments in sidebar.", "description": "Controls the state of the sidebar upon load.\n -1 = Default (uses PageMode if available, otherwise the last position if available/enabled).\n 0 = Do not show sidebar.\n 1 = Show thumbnails in sidebar.\n 2 = Show document outline in sidebar.\n 3 = Show attachments in sidebar.",
"type": "integer", "type": "integer",
"enum": [ "enum": [-1, 0, 1, 2, 3],
-1,
0,
1,
2,
3
],
"default": -1 "default": -1
}, },
"enableHandToolOnLoad": { "enableHandToolOnLoad": {
@ -63,10 +49,7 @@
"title": "Cursor tool on load", "title": "Cursor tool on load",
"description": "The cursor tool that is enabled upon load.\n 0 = Text selection tool.\n 1 = Hand tool.", "description": "The cursor tool that is enabled upon load.\n 0 = Text selection tool.\n 1 = Hand tool.",
"type": "integer", "type": "integer",
"enum": [ "enum": [0, 1],
0,
1
],
"default": 0 "default": 0
}, },
"pdfBugEnabled": { "pdfBugEnabled": {
@ -120,23 +103,14 @@
"title": "Text layer mode", "title": "Text layer mode",
"description": "Controls if the text layer is enabled, and the selection mode that is used.\n 0 = Disabled.\n 1 = Enabled.", "description": "Controls if the text layer is enabled, and the selection mode that is used.\n 0 = Disabled.\n 1 = Enabled.",
"type": "integer", "type": "integer",
"enum": [ "enum": [0, 1],
0,
1
],
"default": 1 "default": 1
}, },
"externalLinkTarget": { "externalLinkTarget": {
"title": "External links target window", "title": "External links target window",
"description": "Controls how external links will be opened.\n 0 = default.\n 1 = replaces current window.\n 2 = new window/tab.\n 3 = parent.\n 4 = in top window.", "description": "Controls how external links will be opened.\n 0 = default.\n 1 = replaces current window.\n 2 = new window/tab.\n 3 = parent.\n 4 = in top window.",
"type": "integer", "type": "integer",
"enum": [ "enum": [0, 1, 2, 3, 4],
0,
1,
2,
3,
4
],
"default": 0 "default": 0
}, },
"disablePageLabels": { "disablePageLabels": {
@ -156,22 +130,12 @@
}, },
"annotationMode": { "annotationMode": {
"type": "integer", "type": "integer",
"enum": [ "enum": [0, 1, 2, 3],
0,
1,
2,
3
],
"default": 2 "default": 2
}, },
"annotationEditorMode": { "annotationEditorMode": {
"type": "integer", "type": "integer",
"enum": [ "enum": [-1, 0, 3, 15],
-1,
0,
3,
15
],
"default": 0 "default": 0
}, },
"enablePermissions": { "enablePermissions": {
@ -202,25 +166,14 @@
"title": "Scroll mode on load", "title": "Scroll mode on load",
"description": "Controls how the viewer scrolls upon load.\n -1 = Default (uses the last position if available/enabled).\n 3 = Page scrolling.\n 0 = Vertical scrolling.\n 1 = Horizontal scrolling.\n 2 = Wrapped scrolling.", "description": "Controls how the viewer scrolls upon load.\n -1 = Default (uses the last position if available/enabled).\n 3 = Page scrolling.\n 0 = Vertical scrolling.\n 1 = Horizontal scrolling.\n 2 = Wrapped scrolling.",
"type": "integer", "type": "integer",
"enum": [ "enum": [-1, 0, 1, 2, 3],
-1,
0,
1,
2,
3
],
"default": -1 "default": -1
}, },
"spreadModeOnLoad": { "spreadModeOnLoad": {
"title": "Spread mode on load", "title": "Spread mode on load",
"description": "Whether the viewer should join pages into spreads upon load.\n -1 = Default (uses the last position if available/enabled).\n 0 = No spreads.\n 1 = Odd spreads.\n 2 = Even spreads.", "description": "Whether the viewer should join pages into spreads upon load.\n -1 = Default (uses the last position if available/enabled).\n 0 = No spreads.\n 1 = Odd spreads.\n 2 = Even spreads.",
"type": "integer", "type": "integer",
"enum": [ "enum": [-1, 0, 1, 2],
-1,
0,
1,
2
],
"default": -1 "default": -1
}, },
"forcePageColors": { "forcePageColors": {

View File

@ -1936,7 +1936,7 @@ gulp.task(
gulp.task("lint", function (done) { gulp.task("lint", function (done) {
console.log(); console.log();
console.log("### Linting JS/CSS files"); console.log("### Linting JS/CSS/JSON files");
// Ensure that we lint the Firefox specific *.jsm files too. // Ensure that we lint the Firefox specific *.jsm files too.
const esLintOptions = [ const esLintOptions = [
@ -1959,6 +1959,16 @@ gulp.task("lint", function (done) {
styleLintOptions.push("--fix"); styleLintOptions.push("--fix");
} }
const prettierOptions = [
"node_modules/prettier/bin/prettier.cjs",
"**/*.json",
];
if (process.argv.includes("--fix")) {
prettierOptions.push("--log-level", "silent", "--write");
} else {
prettierOptions.push("--log-level", "warn", "--check");
}
const esLintProcess = startNode(esLintOptions, { stdio: "inherit" }); const esLintProcess = startNode(esLintOptions, { stdio: "inherit" });
esLintProcess.on("close", function (esLintCode) { esLintProcess.on("close", function (esLintCode) {
if (esLintCode !== 0) { if (esLintCode !== 0) {
@ -1972,10 +1982,18 @@ gulp.task("lint", function (done) {
done(new Error("Stylelint failed.")); done(new Error("Stylelint failed."));
return; return;
} }
const prettierProcess = startNode(prettierOptions, { stdio: "inherit" });
prettierProcess.on("close", function (prettierCode) {
if (prettierCode !== 0) {
done(new Error("Prettier failed."));
return;
}
console.log("files checked, no errors found"); console.log("files checked, no errors found");
done(); done();
}); });
}); });
});
}); });
gulp.task( gulp.task(

File diff suppressed because it is too large Load Diff

View File

@ -11,16 +11,11 @@
"baseUrl": "./", "baseUrl": "./",
"strict": true, "strict": true,
"types": [], "types": [],
"lib": [ "lib": ["ESNext", "DOM"],
"ESNext",
"DOM"
],
"paths": { "paths": {
"pdfjs-dist": ["../../build/typestest"], "pdfjs-dist": ["../../build/typestest"],
"pdfjs-dist/*": ["../../build/typestest/*"] "pdfjs-dist/*": ["../../build/typestest/*"]
} }
}, },
"exclude": [ "exclude": ["node_modules"]
"node_modules"
]
} }

View File

@ -1,9 +1,7 @@
{ {
"spec_dir": "build/lib-legacy/test/unit", "spec_dir": "build/lib-legacy/test/unit",
"helpers": [ "helpers": ["clitests_helper.js"],
"clitests_helper.js"
],
"spec_files": [ "spec_files": [
"annotation_spec.js", "annotation_spec.js",

View File

@ -19,8 +19,5 @@
"web-l10n_utils": ["./web/l10n_utils"] "web-l10n_utils": ["./web/l10n_utils"]
} }
}, },
"files": [ "files": ["src/pdf.js", "web/pdf_viewer.component.js"]
"src/pdf.js",
"web/pdf_viewer.component.js"
]
} }