Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit b51bac9

Browse files
Adding of eslint.
1. Adding of eslint warning disables to app.js 2. Installing of eslint dependencies to the project. 3. Adding of eslint.config.mjs.
1 parent 89b71b6 commit b51bac9

File tree

4 files changed

+108
-26
lines changed

4 files changed

+108
-26
lines changed

app/app.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
/* eslint-disable-next-line no-undef */
12
WebViewer({
23
path: 'lib', // path to the PDFTron 'lib' folder on your server
34
// licenseKey: 'Insert commercial license key here after purchase',
45
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
56
// initialDoc: '/path/to/my/file.pdf', // You can also use documents on your server
67
}, document.getElementById('viewer'))
7-
.then(function(instance) {
8-
const { documentViewer, annotationManager } = instance.Core;
9-
// call methods from instance, documentViewer and annotationManager as needed
8+
.then(function(instance) {
9+
const { documentViewer, annotationManager } = instance.Core;
10+
// call methods from instance, documentViewer and annotationManager as needed
1011

11-
// you can also access major namespaces from the instance as follows:
12-
// const Tools = instance.Core.Tools;
13-
// const Annotations = instance.Core.Annotations;
12+
// you can also access major namespaces from the instance as follows:
13+
// const Tools = instance.Core.Tools;
14+
// const Annotations = instance.Core.Annotations;
1415

15-
// change to dark theme
16-
instance.UI.setTheme('dark');
16+
// change to dark theme
17+
instance.UI.setTheme('dark');
1718

18-
documentViewer.addEventListener('documentLoaded', function() {
19+
documentViewer.addEventListener('documentLoaded', function() {
1920
// call methods relating to the loaded document
21+
});
2022
});
21-
});
23+
/*eslint no-unused-vars: "warn"*/

eslint.config.mjs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
4+
export default [
5+
js.configs.recommended,
6+
{ ignores: ["**/node_modules/", "**/.git/", "**/app/lib/*"] },
7+
{ files: ["**/*.{js,mjs}"] },
8+
{
9+
languageOptions: {
10+
ecmaVersion: "latest",
11+
sourceType: "module",
12+
globals: {
13+
...globals.browser,
14+
...globals.node
15+
}
16+
},
17+
"rules": {
18+
"quotes": [
19+
0,
20+
"single",
21+
{
22+
"allowTemplateLiterals": true
23+
}
24+
],
25+
"curly": 2,
26+
"strict": [2, "never"],
27+
"semi": [2, "always"],
28+
"no-redeclare": [
29+
2,
30+
{
31+
"builtinGlobals": true
32+
}
33+
],
34+
"brace-style": 2,
35+
"no-alert": 0,
36+
"no-console": [
37+
0,
38+
{
39+
"allow": ["warn", "error"]
40+
}
41+
],
42+
"object-shorthand": [2, "always"],
43+
"arrow-parens": [2, "as-needed"],
44+
"no-useless-escape": 0,
45+
"eqeqeq": 2,
46+
"jsx-quotes": 2,
47+
"indent": [
48+
2,
49+
2,
50+
{
51+
"MemberExpression": 1,
52+
"ArrayExpression": 1,
53+
"ImportDeclaration": 1,
54+
"SwitchCase": 1,
55+
"FunctionExpression": {
56+
"body": 1
57+
}
58+
}
59+
],
60+
"keyword-spacing": 2,
61+
"space-before-blocks": 2,
62+
"arrow-spacing": 2,
63+
"object-curly-spacing": [2, "always"],
64+
"@pdftron/webviewer/no-string-events": 0,
65+
66+
// these are inherited from git WebViewer's eslint configuration
67+
"no-use-before-define": 0,
68+
"implicit-arrow-linebreak": 0,
69+
"operator-linebreak": 0,
70+
"function-paren-newline": 0,
71+
"object-curly-newline": 0,
72+
"no-nested-ternary": 0,
73+
"no-unexpected-multiline": 0,
74+
"no-unused-expressions": 0
75+
}
76+
}
77+
];

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
"scripts": {
55
"start": "concurrently \"npm run server\" \"start http://localhost:3000\"",
66
"server": "supervisor -k -e html,js -i .git/,node_modules/ -- server.js",
7-
"postinstall": "node tools/copy-webviewer-files.js"
7+
"postinstall": "node tools/copy-webviewer-files.js",
8+
"lint": "eslint --fix ."
89
},
910
"repository": {
1011
"type": "git",
1112
"url": ""
1213
},
1314
"author": "PDFTron Systems Inc.",
1415
"devDependencies": {
16+
"@eslint/js": "^9.9.1",
17+
"eslint": "^9.9.1",
1518
"body-parser": "^1.20.2",
1619
"express": "^4.19.2",
1720
"fs-extra": "^11.2.0",

server.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// modified original source from https://www.npmjs.com/package/reload#using-reload-in-express
22

3-
var express = require('express')
4-
var http = require('http')
5-
var path = require('path')
6-
var bodyParser = require('body-parser')
7-
var logger = require('morgan')
3+
var express = require('express');
4+
var http = require('http');
5+
var path = require('path');
6+
var bodyParser = require('body-parser');
7+
var logger = require('morgan');
88

9-
var app = express()
9+
var app = express();
1010

11-
var appDir = path.join(__dirname, 'app')
11+
var appDir = path.join(__dirname, 'app');
1212

13-
app.set('port', process.env.PORT || 3000)
14-
app.use(logger('dev'))
15-
app.use(bodyParser.json()) // Parses json, multi-part (file), url-encoded
13+
app.set('port', process.env.PORT || 3000);
14+
app.use(logger('dev'));
15+
app.use(bodyParser.json()); // Parses json, multi-part (file), url-encoded
1616

1717
app.get('/', function (req, res) {
18-
res.sendFile(path.join(appDir, 'index.html'))
19-
})
18+
res.sendFile(path.join(appDir, 'index.html'));
19+
});
2020

2121
app.use(express.static(appDir));
2222

23-
var server = http.createServer(app)
23+
var server = http.createServer(app);
2424

2525
server.listen(app.get('port'), function () {
26-
console.log('Web server listening on port ' + app.get('port'))
27-
})
26+
console.log('Web server listening on port ' + app.get('port'));
27+
});

0 commit comments

Comments
 (0)