-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support of eslint and typescript, plus more tests and excep…
…tion handlings (#346) * feat: add eslint, fix issue #321, add test PDF for #321:image exception will only be warned in log, won't stop the text and form parsing * fix: issue #318, fixed together with #321 * fix: issue #343, resolve pkInfo at build time * fix: issue #255 and #277, keep parsing if img data is not resolved * maint: add ts dependency and config, remove root pdf2json.js, use ./bin/pdf2json.js instead * maint: replace lib/p2jcom*.js with src/cli/p2jcli*.ts, compied cli is moved to /bin/cli * maint: add compiled bundle to bin/cli and dist * maint: remove unnecessary build artifacts * build: add prepare scripts * test: add more page content verification in test * test: add more cli tests after jest * fix: auto create output dir in CLI to make more tests run without setting up directory structure * fix: #262: correct the condition check, also add i262_4hXzVq.pdf to test/misc
- Loading branch information
Showing
38 changed files
with
2,243 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2022, | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": ["/dist/", "/bin/", "/test/", "/node_modules/", "/base/", "/lib/pdfjs-code.js"], | ||
"overrides": [{ | ||
"files": ["*.js", "*.ts"], | ||
"rules": { | ||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"], | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
{ | ||
"selector": "variable", | ||
"format": ["camelCase", "PascalCase", "UPPER_CASE"], | ||
"filter": { | ||
"regex": "^_", | ||
"match": false | ||
} | ||
}, | ||
{ | ||
"selector": "function", | ||
"format": ["camelCase", "PascalCase"] | ||
}, | ||
{ | ||
"selector": "parameter", | ||
"format": ["camelCase", "PascalCase"], | ||
"filter": { | ||
"regex": "^_", | ||
"match": false | ||
} | ||
}, | ||
{ | ||
"selector": "property", | ||
"format": ["camelCase", "PascalCase", "UPPER_CASE"], | ||
"filter": { | ||
"regex": "(x-ide-git-auth|^_|^sys_*|app_id)", | ||
"match": false | ||
} | ||
}, | ||
{ | ||
"selector": "method", | ||
"format": ["camelCase", "PascalCase"], | ||
"filter": { | ||
"regex": "^_", | ||
"match": false | ||
} | ||
}, | ||
{ | ||
"selector": "accessor", | ||
"format": ["camelCase", "PascalCase"] | ||
}, | ||
{ | ||
"selector": "enumMember", | ||
"format": ["camelCase", "PascalCase", "UPPER_CASE"] | ||
}, | ||
{ | ||
"selector": "typeLike", | ||
"format": ["PascalCase"] | ||
} | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"vars": "all", | ||
"args": "after-used", | ||
"argsIgnorePattern": "(^_?|fs|uri|options|opts|source|signal|destination|Uri$|args)", | ||
"ignoreRestSiblings": true, | ||
"destructuredArrayIgnorePattern": "^_?" | ||
} | ||
], | ||
"@typescript-eslint/no-extra-semi": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"arrow-body-style": ["error", "as-needed"], | ||
"dot-notation": ["error"], | ||
"eqeqeq": ["error", "always"], | ||
"no-case-declarations": "error", | ||
"no-duplicate-imports": ["error"], | ||
"no-else-return": [ | ||
"error", | ||
{ | ||
"allowElseIf": true | ||
} | ||
], | ||
"no-eval": [ | ||
"error", | ||
{ | ||
"allowIndirect": false | ||
} | ||
], | ||
"no-iterator": ["error"], | ||
"no-multi-assign": ["error"], | ||
"no-new-func": ["error"], | ||
"no-new-wrappers": ["error"], | ||
"no-object-constructor": ["error"], | ||
"no-param-reassign": "off", | ||
"no-restricted-imports": ["error", "lodash", "moment"], | ||
"no-throw-literal": "warn", | ||
"no-useless-call": ["error"], | ||
"object-curly-spacing": ["error", "always"], | ||
"object-shorthand": [ | ||
"error", | ||
"always", | ||
{ | ||
"avoidExplicitReturnArrows": true | ||
} | ||
], | ||
"prefer-arrow-callback": [ | ||
"error", | ||
{ | ||
"allowNamedFunctions": true | ||
} | ||
], | ||
"prefer-const": ["error"], | ||
"prefer-destructuring": [ | ||
"error", | ||
{ | ||
"object": true, | ||
"array": false | ||
} | ||
], | ||
"prefer-rest-params": ["error"], | ||
"prefer-spread": ["error"], | ||
"prefer-template": ["error"] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ node_modules/ | |
target/ | ||
.idea | ||
.npmrc | ||
vscode/ | ||
dist/ | ||
.vscode/ | ||
lib/pdfjs-code.js | ||
src/**/*.js | ||
/dist/ | ||
/bin/cli/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
...require('prettier-config-standard'), | ||
trailingComma: 'es5', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
import PDFCLI from "../lib/p2jcmd.js"; | ||
import PDFCLI from "./cli/pdfparser_cli.js"; | ||
new PDFCLI().start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.