Skip to content

Commit a2e20cc

Browse files
committed
Lint and cleanup entire project using eslint
1 parent c05940c commit a2e20cc

File tree

88 files changed

+958
-584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+958
-584
lines changed

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage/
2+
shared/pdf_viewer.js
3+
shared/pdf.js
4+
shared/pdf.worker.js
5+
web/shared/

.eslintrc

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
5+
},
6+
7+
"env": {
8+
"es6": true,
9+
"node": true,
10+
"browser": true,
11+
"mocha": true
12+
},
13+
14+
"globals": {
15+
"document": true,
16+
"navigator": true,
17+
"window": true,
18+
"pdfjsViewer": "readeable"
19+
},
20+
21+
"rules": {
22+
"accessor-pairs": 2,
23+
"valid-jsdoc": ["warn", {
24+
"requireParamType": true,
25+
"requireReturn": false,
26+
"requireReturnType": true
27+
}],
28+
"arrow-spacing": [2, { "before": true, "after": true }],
29+
"block-spacing": [2, "always"],
30+
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
31+
"camelcase": 0,
32+
"comma-dangle": [2, "never"],
33+
"comma-spacing": [2, { "before": false, "after": true }],
34+
"comma-style": [2, "last"],
35+
"constructor-super": 2,
36+
"curly": [2, "multi-line"],
37+
"dot-location": [2, "property"],
38+
"eol-last": 2,
39+
"eqeqeq": [1, "allow-null"],
40+
"func-call-spacing": [2, "never"],
41+
"handle-callback-err": [2, "^(err|error)$" ],
42+
"indent": [2, 2, { "SwitchCase": 1 }],
43+
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
44+
"keyword-spacing": [2, { "before": true, "after": true }],
45+
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
46+
"new-parens": 2,
47+
"no-array-constructor": 2,
48+
"no-caller": 2,
49+
"no-class-assign": 2,
50+
"no-cond-assign": 2,
51+
"no-const-assign": 2,
52+
"no-constant-condition": [2, { "checkLoops": false }],
53+
"no-control-regex": 2,
54+
"no-debugger": 2,
55+
"no-delete-var": 2,
56+
"no-dupe-args": 2,
57+
"no-dupe-class-members": 2,
58+
"no-dupe-keys": 2,
59+
"no-duplicate-case": 2,
60+
"no-duplicate-imports": 2,
61+
"no-empty-character-class": 2,
62+
"no-empty-pattern": 2,
63+
"no-eval": 2,
64+
"no-ex-assign": 2,
65+
"no-extend-native": 2,
66+
"no-extra-bind": 2,
67+
"no-extra-boolean-cast": 2,
68+
"no-extra-parens": [2, "functions"],
69+
"no-fallthrough": 2,
70+
"no-floating-decimal": 2,
71+
"no-func-assign": 2,
72+
"no-global-assign": 2,
73+
"no-implied-eval": 2,
74+
"no-inner-declarations": [2, "functions"],
75+
"no-invalid-regexp": 2,
76+
"no-irregular-whitespace": 2,
77+
"no-iterator": 2,
78+
"no-label-var": 2,
79+
"no-labels": [2, { "allowLoop": false, "allowSwitch": false }],
80+
"no-lone-blocks": 2,
81+
"no-mixed-spaces-and-tabs": 2,
82+
"no-multi-spaces": 2,
83+
"no-multi-str": 2,
84+
"no-multiple-empty-lines": [2, { "max": 1 }],
85+
"no-native-reassign": 2,
86+
"no-negated-in-lhs": 2,
87+
"no-new": 2,
88+
"no-new-func": 2,
89+
"no-new-object": 2,
90+
"no-new-require": 2,
91+
"no-new-symbol": 2,
92+
"no-new-wrappers": 2,
93+
"no-obj-calls": 2,
94+
"no-octal": 2,
95+
"no-octal-escape": 2,
96+
"no-path-concat": 2,
97+
"no-proto": 2,
98+
"no-redeclare": 2,
99+
"no-regex-spaces": 2,
100+
"no-return-assign": [2, "except-parens"],
101+
"no-self-assign": 2,
102+
"no-self-compare": 2,
103+
"no-sequences": 2,
104+
"no-shadow-restricted-names": 2,
105+
"no-sparse-arrays": 2,
106+
"no-tabs": 2,
107+
"no-template-curly-in-string": 2,
108+
"no-this-before-super": 2,
109+
"no-throw-literal": 2,
110+
"no-trailing-spaces": 2,
111+
"no-undef": 2,
112+
"no-undef-init": 2,
113+
"no-unexpected-multiline": 2,
114+
"no-unmodified-loop-condition": 2,
115+
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
116+
"no-unreachable": 2,
117+
"no-unsafe-finally": 2,
118+
"no-unsafe-negation": 2,
119+
"no-unused-vars": ["error", { "vars": "all", "args": "none" }],
120+
"no-useless-call": 2,
121+
"no-useless-computed-key": 2,
122+
"no-useless-constructor": 2,
123+
"no-useless-escape": 2,
124+
"no-useless-rename": 2,
125+
"no-whitespace-before-property": 2,
126+
"no-with": 2,
127+
"no-var": 2,
128+
"object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }],
129+
"one-var": [2, { "initialized": "never" }],
130+
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
131+
"padded-blocks": [2, "never"],
132+
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
133+
"rest-spread-spacing": [2, "never"],
134+
"semi": [2, "always"],
135+
"semi-spacing": [2, { "before": false, "after": true }],
136+
"space-before-blocks": [2, "always"],
137+
"space-before-function-paren": [2, {
138+
"anonymous": "never",
139+
"named": "never",
140+
"asyncArrow": "ignore"
141+
}],
142+
"space-in-parens": [2, "never"],
143+
"space-infix-ops": 2,
144+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
145+
"spaced-comment": [2, "always", { "line": { "markers": ["*package", "!", ","] }, "block": { "balanced": true, "markers": ["*package", "!", ","], "exceptions": ["*"] } }],
146+
"template-curly-spacing": [2, "never"],
147+
"unicode-bom": [2, "never"],
148+
"use-isnan": 2,
149+
"valid-typeof": 2,
150+
"wrap-iife": [2, "any", { "functionPrototypeMethods": true }],
151+
"yield-star-spacing": [2, "both"],
152+
"yoda": [2, "never"]
153+
}
154+
}

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ before_script:
1818
- sh -e /etc/init.d/xvfb start
1919

2020
script:
21+
- npm run lint
2122
- npm test
2223
- npm run build
2324

karma.conf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = function(config) {
4545
options: {
4646
presets: ['@babel/preset-env']
4747
}
48-
},
48+
}
4949
/*
5050
{
5151
test: /\.js$/,
@@ -57,7 +57,7 @@ module.exports = function(config) {
5757
}
5858
}
5959
*/
60-
],
60+
]
6161
},
6262
plugins: [
6363
new webpack.DefinePlugin({
@@ -71,13 +71,13 @@ module.exports = function(config) {
7171
stats: {
7272
colors: true
7373
}
74-
},
75-
/*
74+
}
75+
/*
7676
coverageReporter: {
7777
type: 'lcov',
7878
dir: 'coverage/',
7979
subdir: '.'
8080
}
81-
*/
81+
*/
8282
});
8383
};

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"test": "karma start --single-run",
88
"start": "./scripts/web",
9+
"lint": "./node_modules/bin/eslint .",
910
"startindocker": "./scripts/web-docker",
1011
"build": "webpack && MINIFY=1 webpack",
1112
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
@@ -31,6 +32,7 @@
3132
"babel-plugin-add-module-exports": "^1.0.0",
3233
"chai": "^4.2.0",
3334
"coveralls": "^3.0.2",
35+
"eslint": "^5.16.0",
3436
"istanbul-instrumenter-loader": "^3.0.1",
3537
"karma": "^4.0.1",
3638
"karma-chrome-launcher": "^2.2.0",

sandbox/basic/annotations.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default [
2323
}]
2424
}),
2525
mockText(125, 155, 'Highlight this text so it stands out'),
26-
26+
2727
mockLabel(230, 'Area:'),
2828
mockText(125, 230, 'I\'m the text in the box'),
2929
mock('area', {
@@ -32,7 +32,7 @@ export default [
3232
width: 175,
3333
height: 40
3434
}),
35-
35+
3636
mockLabel(305, 'Strikeout:'),
3737
mockText(125, 305, 'Text to be struck from the record'),
3838
mock('strikeout', {
@@ -42,7 +42,7 @@ export default [
4242
y: 320,
4343
width: 270,
4444
height: 1
45-
}],
45+
}]
4646
}),
4747

4848
mockLabel(380, 'Textbox:'),
@@ -61,12 +61,12 @@ export default [
6161
x: 125,
6262
y: 460
6363
}),
64-
64+
6565
mockLabel(530, 'Drawing:'),
6666
mock('drawing', {
6767
color: '000000',
6868
x: 100,
6969
y: 50,
70-
lines: [[244, 561],[244, 560],[243, 559],[242, 559],[242, 557],[241, 556],[241, 556],[241, 555],[241, 554],[240, 553],[239, 552],[239, 552],[237, 552],[237, 551],[237, 550],[235, 550],[235, 548],[234, 547],[233, 547],[231, 547],[230, 546],[228, 544],[228, 544],[226, 544],[225, 543],[224, 543],[223, 542],[222, 542],[221, 541],[220, 541],[218, 541],[217, 541],[216, 541],[214, 541],[213, 541],[212, 540],[211, 540],[209, 540],[208, 540],[205, 540],[205, 540],[202, 540],[201, 540],[198, 540],[197, 540],[195, 540],[194, 540],[192, 540],[191, 540],[190, 540],[189, 540],[186, 541],[185, 541],[184, 542],[183, 542],[181, 543],[180, 543],[179, 544],[177, 544],[176, 544],[174, 546],[174, 547],[174, 548],[173, 549],[172, 549],[172, 550],[171, 551],[170, 551],[169, 552],[167, 553],[167, 554],[165, 556],[164, 557],[162, 558],[161, 560],[159, 561],[159, 563],[156, 564],[154, 566],[153, 566],[152, 568],[151, 569],[151, 570],[151, 571],[151, 572],[151, 573],[151, 574],[151, 575],[151, 576],[151, 577],[151, 579],[151, 580],[151, 581],[151, 583],[151, 584],[152, 585],[152, 587],[152, 588],[157, 600],[157, 603],[159, 606],[162, 611],[163, 614],[165, 615],[167, 619],[168, 620],[171, 622],[174, 625],[175, 625],[175, 626],[177, 626],[177, 626],[180, 626],[182, 626],[183, 626],[186, 626],[188, 628],[191, 628],[192, 628],[195, 628],[197, 628],[200, 628],[203, 628],[208, 630],[211, 631],[214, 631],[217, 631],[220, 633],[224, 634],[225, 634],[230, 636],[233, 636],[237, 637],[240, 639],[243, 639],[247, 642],[250, 643],[254, 646],[257, 648],[260, 651],[262, 653],[263, 653],[265, 656],[268, 657],[270, 659],[271, 661],[273, 663],[276, 666],[277, 668],[279, 670],[280, 672],[281, 674],[282, 676],[282, 677],[283, 679],[283, 681],[283, 683],[283, 685],[283, 687],[283, 689],[283, 691],[283, 693],[283, 694],[283, 697],[283, 698],[283, 699],[283, 701],[283, 702],[283, 704],[282, 705],[282, 706],[280, 708],[280, 708],[280, 709],[280, 710],[278, 711],[277, 712],[274, 715],[272, 717],[269, 718],[268, 719],[266, 720],[265, 722],[262, 723],[260, 725],[257, 726],[254, 727],[251, 728],[247, 729],[243, 731],[239, 731],[236, 731],[231, 732],[227, 732],[223, 732],[219, 732],[214, 732],[213, 732],[207, 732],[203, 732],[200, 732],[196, 732],[193, 732],[191, 732],[188, 732],[187, 731],[185, 731],[183, 731],[182, 731],[179, 729],[177, 729],[177, 728],[176, 727],[174, 727],[174, 726],[173, 725],[172, 725],[172, 724],[171, 722],[171, 722],[169, 722],[169, 720],[168, 720],[167, 719],[167, 717],[166, 716],[166, 714],[166, 713],[165, 711],[165, 710],[165, 708],[165, 707],[165, 706],[165, 705],[165, 704],[165, 702],[165, 702],[165, 700],[165, 699],[165, 698],[165, 697],[165, 696],[165, 695],[165, 692],[165, 691],[165, 690],[165, 689],[165, 688],[165, 687],[165, 685],[165, 685],[165, 684],[165, 682],[165, 682],[165, 680],[165, 679],[165, 678],[165, 678],[165, 676],[165, 676],[166, 675],[166, 674],[166, 673],[168, 673],[168, 672],[168, 671],[169, 670],[169, 669],[169, 668],[170, 667],[172, 667],[172, 666],[174, 664],[175, 663],[176, 661],[177, 660],[178, 660],[179, 658],[180, 657],[180, 656],[181, 655],[182, 654],[183, 653],[183, 652],[184, 650],[185, 650],[186, 649],[186, 648],[186, 647],[186, 646],[187, 644],[189, 643],[189, 642],[192, 640],[192, 639],[194, 639],[198, 637],[200, 637],[206, 634],[209, 632],[213, 631],[215, 629],[217, 628],[221, 626],[224, 626],[226, 625],[229, 623],[232, 623],[235, 621],[238, 620],[240, 620],[242, 619],[244, 617],[246, 617],[247, 616],[249, 615],[250, 615],[252, 615],[252, 614],[254, 612],[255, 612],[256, 611],[256, 610],[258, 610],[258, 609],[259, 608],[260, 607],[260, 606],[262, 606],[262, 605],[262, 604],[262, 603],[262, 603],[262, 602],[262, 601],[262, 600],[262, 599],[262, 598],[262, 597],[262, 596],[262, 595],[262, 594],[262, 593],[262, 592],[262, 592],[262, 590],[262, 589],[264, 587],[264, 587],[264, 586],[264, 585],[264, 582],[264, 581],[263, 581],[263, 579],[263, 579],[262, 579],[262, 578],[262, 576],[262, 576],[262, 575],[261, 574],[261, 573],[260, 572],[260, 571],[260, 570],[258, 570],[258, 569],[257, 568],[256, 567],[256, 566],[255, 566],[255, 566],[253, 566],[252, 565],[251, 565],[251, 564],[250, 564],[250, 563],[249, 563],[249, 562],[248, 562],[248, 561],[248, 561],[248, 560],[247, 560],[247, 559],[246, 559],[246, 557],[245, 557],[245, 557],[245, 557],[245, 556]]
70+
lines: [[244, 561], [244, 560], [243, 559], [242, 559], [242, 557], [241, 556], [241, 556], [241, 555], [241, 554], [240, 553], [239, 552], [239, 552], [237, 552], [237, 551], [237, 550], [235, 550], [235, 548], [234, 547], [233, 547], [231, 547], [230, 546], [228, 544], [228, 544], [226, 544], [225, 543], [224, 543], [223, 542], [222, 542], [221, 541], [220, 541], [218, 541], [217, 541], [216, 541], [214, 541], [213, 541], [212, 540], [211, 540], [209, 540], [208, 540], [205, 540], [205, 540], [202, 540], [201, 540], [198, 540], [197, 540], [195, 540], [194, 540], [192, 540], [191, 540], [190, 540], [189, 540], [186, 541], [185, 541], [184, 542], [183, 542], [181, 543], [180, 543], [179, 544], [177, 544], [176, 544], [174, 546], [174, 547], [174, 548], [173, 549], [172, 549], [172, 550], [171, 551], [170, 551], [169, 552], [167, 553], [167, 554], [165, 556], [164, 557], [162, 558], [161, 560], [159, 561], [159, 563], [156, 564], [154, 566], [153, 566], [152, 568], [151, 569], [151, 570], [151, 571], [151, 572], [151, 573], [151, 574], [151, 575], [151, 576], [151, 577], [151, 579], [151, 580], [151, 581], [151, 583], [151, 584], [152, 585], [152, 587], [152, 588], [157, 600], [157, 603], [159, 606], [162, 611], [163, 614], [165, 615], [167, 619], [168, 620], [171, 622], [174, 625], [175, 625], [175, 626], [177, 626], [177, 626], [180, 626], [182, 626], [183, 626], [186, 626], [188, 628], [191, 628], [192, 628], [195, 628], [197, 628], [200, 628], [203, 628], [208, 630], [211, 631], [214, 631], [217, 631], [220, 633], [224, 634], [225, 634], [230, 636], [233, 636], [237, 637], [240, 639], [243, 639], [247, 642], [250, 643], [254, 646], [257, 648], [260, 651], [262, 653], [263, 653], [265, 656], [268, 657], [270, 659], [271, 661], [273, 663], [276, 666], [277, 668], [279, 670], [280, 672], [281, 674], [282, 676], [282, 677], [283, 679], [283, 681], [283, 683], [283, 685], [283, 687], [283, 689], [283, 691], [283, 693], [283, 694], [283, 697], [283, 698], [283, 699], [283, 701], [283, 702], [283, 704], [282, 705], [282, 706], [280, 708], [280, 708], [280, 709], [280, 710], [278, 711], [277, 712], [274, 715], [272, 717], [269, 718], [268, 719], [266, 720], [265, 722], [262, 723], [260, 725], [257, 726], [254, 727], [251, 728], [247, 729], [243, 731], [239, 731], [236, 731], [231, 732], [227, 732], [223, 732], [219, 732], [214, 732], [213, 732], [207, 732], [203, 732], [200, 732], [196, 732], [193, 732], [191, 732], [188, 732], [187, 731], [185, 731], [183, 731], [182, 731], [179, 729], [177, 729], [177, 728], [176, 727], [174, 727], [174, 726], [173, 725], [172, 725], [172, 724], [171, 722], [171, 722], [169, 722], [169, 720], [168, 720], [167, 719], [167, 717], [166, 716], [166, 714], [166, 713], [165, 711], [165, 710], [165, 708], [165, 707], [165, 706], [165, 705], [165, 704], [165, 702], [165, 702], [165, 700], [165, 699], [165, 698], [165, 697], [165, 696], [165, 695], [165, 692], [165, 691], [165, 690], [165, 689], [165, 688], [165, 687], [165, 685], [165, 685], [165, 684], [165, 682], [165, 682], [165, 680], [165, 679], [165, 678], [165, 678], [165, 676], [165, 676], [166, 675], [166, 674], [166, 673], [168, 673], [168, 672], [168, 671], [169, 670], [169, 669], [169, 668], [170, 667], [172, 667], [172, 666], [174, 664], [175, 663], [176, 661], [177, 660], [178, 660], [179, 658], [180, 657], [180, 656], [181, 655], [182, 654], [183, 653], [183, 652], [184, 650], [185, 650], [186, 649], [186, 648], [186, 647], [186, 646], [187, 644], [189, 643], [189, 642], [192, 640], [192, 639], [194, 639], [198, 637], [200, 637], [206, 634], [209, 632], [213, 631], [215, 629], [217, 628], [221, 626], [224, 626], [226, 625], [229, 623], [232, 623], [235, 621], [238, 620], [240, 620], [242, 619], [244, 617], [246, 617], [247, 616], [249, 615], [250, 615], [252, 615], [252, 614], [254, 612], [255, 612], [256, 611], [256, 610], [258, 610], [258, 609], [259, 608], [260, 607], [260, 606], [262, 606], [262, 605], [262, 604], [262, 603], [262, 603], [262, 602], [262, 601], [262, 600], [262, 599], [262, 598], [262, 597], [262, 596], [262, 595], [262, 594], [262, 593], [262, 592], [262, 592], [262, 590], [262, 589], [264, 587], [264, 587], [264, 586], [264, 585], [264, 582], [264, 581], [263, 581], [263, 579], [263, 579], [262, 579], [262, 578], [262, 576], [262, 576], [262, 575], [261, 574], [261, 573], [260, 572], [260, 571], [260, 570], [258, 570], [258, 569], [257, 568], [256, 567], [256, 566], [255, 566], [255, 566], [253, 566], [252, 565], [251, 565], [251, 564], [250, 564], [250, 563], [249, 563], [249, 562], [248, 562], [248, 561], [248, 561], [248, 560], [247, 560], [247, 559], [246, 559], [246, 557], [245, 557], [245, 557], [245, 557], [245, 556]]
7171
})
7272
];

sandbox/draw/index.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const { UI } = PDFJSAnnotate;
66
const svg = document.getElementById('svg');
77
const DOCUMENT_ID = window.location.pathname.replace(/\/$/, '');
88
const PAGE_NUMBER = 1;
9-
let annotations;
109

1110
PDFJSAnnotate.setStoreAdapter(new PDFJSAnnotate.LocalStoreAdapter());
1211

@@ -16,14 +15,14 @@ PDFJSAnnotate.getAnnotations(DOCUMENT_ID, PAGE_NUMBER).then((annotations) => {
1615
});
1716

1817
// Pen stuff
19-
(function () {
18+
(function() {
2019
let penColor;
2120
let penSize;
2221

2322
function initPen() {
2423
let size = document.querySelector('.toolbar .pen-size');
25-
for (let i=0; i<20; i++) {
26-
size.appendChild(new Option(i+1, i+1));
24+
for (let i = 0; i < 20; i++) {
25+
size.appendChild(new Option(i + 1, i + 1));
2726
}
2827

2928
setPen(
@@ -32,7 +31,7 @@ PDFJSAnnotate.getAnnotations(DOCUMENT_ID, PAGE_NUMBER).then((annotations) => {
3231
);
3332

3433
UI.enablePen();
35-
initColorPicker(document.querySelector('.toolbar .pen-color'), penColor, function (value) {
34+
initColorPicker(document.querySelector('.toolbar .pen-color'), penColor, function(value) {
3635
setPen(penSize, value);
3736
});
3837
}
@@ -51,7 +50,7 @@ PDFJSAnnotate.getAnnotations(DOCUMENT_ID, PAGE_NUMBER).then((annotations) => {
5150
modified = true;
5251
penColor = color;
5352
localStorage.setItem(`${DOCUMENT_ID}/pen/color`, penColor);
54-
53+
5554
let selected = document.querySelector('.toolbar .pen-color.color-selected');
5655
if (selected) {
5756
selected.classList.remove('color-selected');

0 commit comments

Comments
 (0)