Skip to content

Commit

Permalink
Lint and cleanup entire project using eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Apr 8, 2019
1 parent c05940c commit a2e20cc
Show file tree
Hide file tree
Showing 88 changed files with 958 additions and 584 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage/
shared/pdf_viewer.js
shared/pdf.js
shared/pdf.worker.js
web/shared/
154 changes: 154 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},

"env": {
"es6": true,
"node": true,
"browser": true,
"mocha": true
},

"globals": {
"document": true,
"navigator": true,
"window": true,
"pdfjsViewer": "readeable"
},

"rules": {
"accessor-pairs": 2,
"valid-jsdoc": ["warn", {
"requireParamType": true,
"requireReturn": false,
"requireReturnType": true
}],
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "stroustrup", { "allowSingleLine": true }],
"camelcase": 0,
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [1, "allow-null"],
"func-call-spacing": [2, "never"],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-constant-condition": [2, { "checkLoops": false }],
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-duplicate-imports": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-global-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": [2, { "allowLoop": false, "allowSwitch": false }],
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-symbol": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-path-concat": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": [2, "except-parens"],
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-sparse-arrays": 2,
"no-tabs": 2,
"no-template-curly-in-string": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unsafe-negation": 2,
"no-unused-vars": ["error", { "vars": "all", "args": "none" }],
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-constructor": 2,
"no-useless-escape": 2,
"no-useless-rename": 2,
"no-whitespace-before-property": 2,
"no-with": 2,
"no-var": 2,
"object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }],
"one-var": [2, { "initialized": "never" }],
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [2, "never"],
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"rest-spread-spacing": [2, "never"],
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, {
"anonymous": "never",
"named": "never",
"asyncArrow": "ignore"
}],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always", { "line": { "markers": ["*package", "!", ","] }, "block": { "balanced": true, "markers": ["*package", "!", ","], "exceptions": ["*"] } }],
"template-curly-spacing": [2, "never"],
"unicode-bom": [2, "never"],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any", { "functionPrototypeMethods": true }],
"yield-star-spacing": [2, "both"],
"yoda": [2, "never"]
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ before_script:
- sh -e /etc/init.d/xvfb start

script:
- npm run lint
- npm test
- npm run build

Expand Down
10 changes: 5 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function(config) {
options: {
presets: ['@babel/preset-env']
}
},
}
/*
{
test: /\.js$/,
Expand All @@ -57,7 +57,7 @@ module.exports = function(config) {
}
}
*/
],
]
},
plugins: [
new webpack.DefinePlugin({
Expand All @@ -71,13 +71,13 @@ module.exports = function(config) {
stats: {
colors: true
}
},
/*
}
/*
coverageReporter: {
type: 'lcov',
dir: 'coverage/',
subdir: '.'
}
*/
*/
});
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"test": "karma start --single-run",
"start": "./scripts/web",
"lint": "./node_modules/bin/eslint .",
"startindocker": "./scripts/web-docker",
"build": "webpack && MINIFY=1 webpack",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
Expand All @@ -31,6 +32,7 @@
"babel-plugin-add-module-exports": "^1.0.0",
"chai": "^4.2.0",
"coveralls": "^3.0.2",
"eslint": "^5.16.0",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
Expand Down
10 changes: 5 additions & 5 deletions sandbox/basic/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default [
}]
}),
mockText(125, 155, 'Highlight this text so it stands out'),

mockLabel(230, 'Area:'),
mockText(125, 230, 'I\'m the text in the box'),
mock('area', {
Expand All @@ -32,7 +32,7 @@ export default [
width: 175,
height: 40
}),

mockLabel(305, 'Strikeout:'),
mockText(125, 305, 'Text to be struck from the record'),
mock('strikeout', {
Expand All @@ -42,7 +42,7 @@ export default [
y: 320,
width: 270,
height: 1
}],
}]
}),

mockLabel(380, 'Textbox:'),
Expand All @@ -61,12 +61,12 @@ export default [
x: 125,
y: 460
}),

mockLabel(530, 'Drawing:'),
mock('drawing', {
color: '000000',
x: 100,
y: 50,
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]]
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]]
})
];
11 changes: 5 additions & 6 deletions sandbox/draw/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { UI } = PDFJSAnnotate;
const svg = document.getElementById('svg');
const DOCUMENT_ID = window.location.pathname.replace(/\/$/, '');
const PAGE_NUMBER = 1;
let annotations;

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

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

// Pen stuff
(function () {
(function() {
let penColor;
let penSize;

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

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

UI.enablePen();
initColorPicker(document.querySelector('.toolbar .pen-color'), penColor, function (value) {
initColorPicker(document.querySelector('.toolbar .pen-color'), penColor, function(value) {
setPen(penSize, value);
});
}
Expand All @@ -51,7 +50,7 @@ PDFJSAnnotate.getAnnotations(DOCUMENT_ID, PAGE_NUMBER).then((annotations) => {
modified = true;
penColor = color;
localStorage.setItem(`${DOCUMENT_ID}/pen/color`, penColor);

let selected = document.querySelector('.toolbar .pen-color.color-selected');
if (selected) {
selected.classList.remove('color-selected');
Expand Down
Loading

0 comments on commit a2e20cc

Please sign in to comment.