Migrate to ESLint flat config
Flat config is the new config system used by ESLint 9. To make the migration easier, they also added flat config support to ESLint 8. This commit migrates the various ESLint configs in the repository to use the new system, **without** upgrading to ESLint 9 yet.
This commit is contained in:
parent
7a962031e9
commit
9e6ff979db
@ -1,13 +0,0 @@
|
|||||||
build/
|
|
||||||
l10n/
|
|
||||||
docs/
|
|
||||||
node_modules/
|
|
||||||
external/bcmaps/
|
|
||||||
external/builder/fixtures/
|
|
||||||
external/builder/fixtures_babel/
|
|
||||||
external/quickjs/
|
|
||||||
external/openjpeg/
|
|
||||||
test/tmp/
|
|
||||||
test/pdfs/
|
|
||||||
web/locale/
|
|
||||||
*~/
|
|
||||||
265
.eslintrc
265
.eslintrc
@ -1,265 +0,0 @@
|
|||||||
{
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2022,
|
|
||||||
"sourceType": "module",
|
|
||||||
},
|
|
||||||
|
|
||||||
"plugins": [
|
|
||||||
"import",
|
|
||||||
"json",
|
|
||||||
"no-unsanitized",
|
|
||||||
"perfectionist",
|
|
||||||
"unicorn",
|
|
||||||
],
|
|
||||||
|
|
||||||
"extends": [
|
|
||||||
"plugin:json/recommended",
|
|
||||||
"plugin:prettier/recommended"
|
|
||||||
],
|
|
||||||
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es2022": true,
|
|
||||||
"worker": true,
|
|
||||||
},
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"PDFJSDev": "readonly",
|
|
||||||
"__non_webpack_import__": "readonly",
|
|
||||||
},
|
|
||||||
|
|
||||||
"rules": {
|
|
||||||
// Plugins
|
|
||||||
"import/export": "error",
|
|
||||||
"import/exports-last": "error",
|
|
||||||
"import/extensions": ["error", "always", { "ignorePackages": true, }],
|
|
||||||
"import/first": "error",
|
|
||||||
"import/named": "error",
|
|
||||||
"import/no-cycle": "error",
|
|
||||||
"import/no-empty-named-blocks": "error",
|
|
||||||
"import/no-commonjs": "error",
|
|
||||||
"import/no-mutable-exports": "error",
|
|
||||||
"import/no-self-import": "error",
|
|
||||||
"import/no-unresolved": ["error", {
|
|
||||||
"ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web", "fluent-bundle", "fluent-dom"],
|
|
||||||
}],
|
|
||||||
"no-unsanitized/method": "error",
|
|
||||||
"no-unsanitized/property": "error",
|
|
||||||
"perfectionist/sort-exports": "error",
|
|
||||||
"perfectionist/sort-named-exports": "error",
|
|
||||||
"unicorn/no-abusive-eslint-disable": "error",
|
|
||||||
"unicorn/no-array-push-push": "error",
|
|
||||||
"unicorn/no-instanceof-array": "error",
|
|
||||||
"unicorn/no-invalid-remove-event-listener": "error",
|
|
||||||
"unicorn/no-new-buffer": "error",
|
|
||||||
"unicorn/no-typeof-undefined": ["error", {
|
|
||||||
"checkGlobalVariables": false,
|
|
||||||
}],
|
|
||||||
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
||||||
"unicorn/no-useless-spread": "error",
|
|
||||||
"unicorn/prefer-array-find": "error",
|
|
||||||
"unicorn/prefer-array-flat": "error",
|
|
||||||
"unicorn/prefer-array-flat-map": "error",
|
|
||||||
"unicorn/prefer-array-index-of": "error",
|
|
||||||
"unicorn/prefer-array-some": "error",
|
|
||||||
"unicorn/prefer-at": "error",
|
|
||||||
"unicorn/prefer-date-now": "error",
|
|
||||||
"unicorn/prefer-dom-node-append": "error",
|
|
||||||
"unicorn/prefer-dom-node-remove": "error",
|
|
||||||
"unicorn/prefer-includes": "error",
|
|
||||||
"unicorn/prefer-logical-operator-over-ternary": "error",
|
|
||||||
"unicorn/prefer-modern-dom-apis": "error",
|
|
||||||
"unicorn/prefer-modern-math-apis": "error",
|
|
||||||
"unicorn/prefer-negative-index": "error",
|
|
||||||
"unicorn/prefer-optional-catch-binding": "error",
|
|
||||||
"unicorn/prefer-regexp-test": "error",
|
|
||||||
"unicorn/prefer-string-replace-all": "error",
|
|
||||||
"unicorn/prefer-string-starts-ends-with": "error",
|
|
||||||
"unicorn/prefer-ternary": ["error", "only-single-line"],
|
|
||||||
"unicorn/throw-new-error": "error",
|
|
||||||
|
|
||||||
// Possible errors
|
|
||||||
"for-direction": "error",
|
|
||||||
"getter-return": "error",
|
|
||||||
"no-async-promise-executor": "error",
|
|
||||||
"no-cond-assign": ["error", "except-parens"],
|
|
||||||
"no-constant-condition": ["error", { "checkLoops": false, }],
|
|
||||||
"no-debugger": "error",
|
|
||||||
"no-dupe-args": "error",
|
|
||||||
"no-dupe-else-if": "error",
|
|
||||||
"no-dupe-keys": "error",
|
|
||||||
"no-duplicate-case": "error",
|
|
||||||
"no-empty": ["error", { "allowEmptyCatch": true, }],
|
|
||||||
"no-empty-character-class": "error",
|
|
||||||
"no-ex-assign": "error",
|
|
||||||
"no-extra-boolean-cast": "error",
|
|
||||||
"no-func-assign": "error",
|
|
||||||
"no-inner-declarations": ["error", "functions"],
|
|
||||||
"no-invalid-regexp": "error",
|
|
||||||
"no-irregular-whitespace": "error",
|
|
||||||
"no-loss-of-precision": "error",
|
|
||||||
"no-obj-calls": "error",
|
|
||||||
"no-promise-executor-return": "error",
|
|
||||||
"no-regex-spaces": "error",
|
|
||||||
"no-setter-return": "error",
|
|
||||||
"no-sparse-arrays": "error",
|
|
||||||
"no-template-curly-in-string": "error",
|
|
||||||
"no-unexpected-multiline": "error",
|
|
||||||
"no-unreachable": "error",
|
|
||||||
"no-unsafe-finally": "error",
|
|
||||||
"no-unsafe-negation": "error",
|
|
||||||
"no-unsafe-optional-chaining": ["error", { "disallowArithmeticOperators": true }],
|
|
||||||
"no-unused-private-class-members": "error",
|
|
||||||
"use-isnan": ["error", { "enforceForIndexOf": true, }],
|
|
||||||
"valid-typeof": ["error", { "requireStringLiterals": true, }],
|
|
||||||
|
|
||||||
// Best Practices
|
|
||||||
"accessor-pairs": ["error", {
|
|
||||||
"setWithoutGet": true,
|
|
||||||
"enforceForClassMembers": true,
|
|
||||||
}],
|
|
||||||
"consistent-return": "error",
|
|
||||||
"curly": ["error", "all"],
|
|
||||||
"default-case-last": "error",
|
|
||||||
"dot-notation": "error",
|
|
||||||
"eqeqeq": ["error", "always"],
|
|
||||||
"grouped-accessor-pairs": ["error", "getBeforeSet"],
|
|
||||||
"no-alert": "error",
|
|
||||||
"no-caller": "error",
|
|
||||||
"no-else-return": "error",
|
|
||||||
"no-empty-pattern": "error",
|
|
||||||
"no-eval": "error",
|
|
||||||
"no-extend-native": "error",
|
|
||||||
"no-extra-bind": "error",
|
|
||||||
"no-extra-label": "error",
|
|
||||||
"no-fallthrough": "error",
|
|
||||||
"no-floating-decimal": "error",
|
|
||||||
"no-global-assign": "error",
|
|
||||||
"no-implied-eval": "error",
|
|
||||||
"no-iterator": "error",
|
|
||||||
"no-lone-blocks": "error",
|
|
||||||
"no-lonely-if": "error",
|
|
||||||
"no-multi-str": "error",
|
|
||||||
"no-new": "error",
|
|
||||||
"no-new-func": "error",
|
|
||||||
"no-new-symbol": "error",
|
|
||||||
"no-new-wrappers": "error",
|
|
||||||
"no-octal-escape": "error",
|
|
||||||
"no-octal": "error",
|
|
||||||
"no-redeclare": "error",
|
|
||||||
"no-return-await": "error",
|
|
||||||
"no-self-assign": "error",
|
|
||||||
"no-self-compare": "error",
|
|
||||||
"no-throw-literal": "error",
|
|
||||||
"no-unused-expressions": "error",
|
|
||||||
"no-unused-labels": "error",
|
|
||||||
"no-useless-call": "error",
|
|
||||||
"no-useless-catch": "error",
|
|
||||||
"no-useless-concat": "error",
|
|
||||||
"no-useless-escape": "error",
|
|
||||||
"no-useless-return": "error",
|
|
||||||
"prefer-promise-reject-errors": "error",
|
|
||||||
"prefer-spread": "error",
|
|
||||||
"wrap-iife": ["error", "any"],
|
|
||||||
"yoda": ["error", "never", {
|
|
||||||
"exceptRange": true,
|
|
||||||
}],
|
|
||||||
|
|
||||||
// Strict Mode
|
|
||||||
"strict": ["off", "global"],
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
"no-delete-var": "error",
|
|
||||||
"no-label-var": "error",
|
|
||||||
"no-shadow": "error",
|
|
||||||
"no-shadow-restricted-names": "error",
|
|
||||||
"no-undef-init": "error",
|
|
||||||
"no-undef": ["error", { "typeof": true, }],
|
|
||||||
"no-unused-vars": ["error", {
|
|
||||||
"vars": "all",
|
|
||||||
"args": "none",
|
|
||||||
}],
|
|
||||||
"no-use-before-define": ["error", {
|
|
||||||
"functions": false,
|
|
||||||
"classes": false,
|
|
||||||
"variables": false,
|
|
||||||
}],
|
|
||||||
|
|
||||||
// Stylistic Issues
|
|
||||||
"lines-between-class-members": ["error", "always"],
|
|
||||||
"max-len": ["error", {
|
|
||||||
"code": 1000,
|
|
||||||
"comments": 80,
|
|
||||||
"ignoreUrls": true
|
|
||||||
}],
|
|
||||||
"new-cap": ["error", { "newIsCap": true, "capIsNew": false, }],
|
|
||||||
"no-array-constructor": "error",
|
|
||||||
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 1, }],
|
|
||||||
"no-nested-ternary": "error",
|
|
||||||
"no-new-object": "error",
|
|
||||||
"no-restricted-syntax": ["error",
|
|
||||||
{
|
|
||||||
"selector": "BinaryExpression[operator='instanceof'][right.name='Object']",
|
|
||||||
"message": "Use `typeof` rather than `instanceof Object`.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "CallExpression[callee.name='assert'][arguments.length!=2]",
|
|
||||||
"message": "`assert()` must always be invoked with two arguments.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "CallExpression[callee.name='isCmd'][arguments.length<2]",
|
|
||||||
"message": "Use `instanceof Cmd` rather than `isCmd()` with one argument.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "CallExpression[callee.name='isDict'][arguments.length<2]",
|
|
||||||
"message": "Use `instanceof Dict` rather than `isDict()` with one argument.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "CallExpression[callee.name='isName'][arguments.length<2]",
|
|
||||||
"message": "Use `instanceof Name` rather than `isName()` with one argument.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "NewExpression[callee.name='Cmd']",
|
|
||||||
"message": "Use `Cmd.get()` rather than `new Cmd()`.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "NewExpression[callee.name='Name']",
|
|
||||||
"message": "Use `Name.get()` rather than `new Name()`.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "NewExpression[callee.name='Ref']",
|
|
||||||
"message": "Use `Ref.get()` rather than `new Ref()`.",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"no-unneeded-ternary": "error",
|
|
||||||
"operator-assignment": "error",
|
|
||||||
"prefer-exponentiation-operator": "error",
|
|
||||||
"spaced-comment": ["error", "always", {
|
|
||||||
"block": {
|
|
||||||
"balanced": true,
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
|
|
||||||
// ECMAScript 6
|
|
||||||
"arrow-body-style": ["error", "as-needed"],
|
|
||||||
"constructor-super": "error",
|
|
||||||
"no-class-assign": "error",
|
|
||||||
"no-const-assign": "error",
|
|
||||||
"no-dupe-class-members": "error",
|
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-this-before-super": "error",
|
|
||||||
"no-useless-computed-key": "error",
|
|
||||||
"no-useless-constructor": "error",
|
|
||||||
"no-useless-rename": "error",
|
|
||||||
"no-var": "error",
|
|
||||||
"object-shorthand": ["error", "always", {
|
|
||||||
"avoidQuotes": true,
|
|
||||||
}],
|
|
||||||
"prefer-const": "error",
|
|
||||||
"require-yield": "error",
|
|
||||||
"sort-imports": ["error", {
|
|
||||||
"ignoreCase": true,
|
|
||||||
}],
|
|
||||||
"template-curly-spacing": ["error", "never"],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
436
eslint.config.mjs
Normal file
436
eslint.config.mjs
Normal file
@ -0,0 +1,436 @@
|
|||||||
|
import globals from "globals";
|
||||||
|
|
||||||
|
import import_ from "eslint-plugin-import";
|
||||||
|
import jasmine from "eslint-plugin-jasmine";
|
||||||
|
import json from "eslint-plugin-json";
|
||||||
|
import noUnsanitized from "eslint-plugin-no-unsanitized";
|
||||||
|
import perfectionist from "eslint-plugin-perfectionist";
|
||||||
|
import prettierRecommended from "eslint-plugin-prettier/recommended";
|
||||||
|
import unicorn from "eslint-plugin-unicorn";
|
||||||
|
|
||||||
|
const jsFiles = folder => {
|
||||||
|
const prefix = folder === "." ? "" : folder + "/";
|
||||||
|
return [prefix + "**/*.js", prefix + "**/*.jsm", prefix + "**/*.mjs"];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Include all files referenced in extensions/chromium/background.js
|
||||||
|
const chromiumExtensionServiceWorkerFiles = [
|
||||||
|
"extensions/chromium/extension-router.js",
|
||||||
|
"extensions/chromium/options/migration.js",
|
||||||
|
"extensions/chromium/pdfHandler.js",
|
||||||
|
"extensions/chromium/preserve-referer.js",
|
||||||
|
"extensions/chromium/suppress-update.js",
|
||||||
|
"extensions/chromium/telemetry.js",
|
||||||
|
];
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: [
|
||||||
|
"**/build/",
|
||||||
|
"**/l10n/",
|
||||||
|
"**/docs/",
|
||||||
|
"**/node_modules/",
|
||||||
|
"external/bcmaps/",
|
||||||
|
"external/builder/fixtures/",
|
||||||
|
"external/builder/fixtures_babel/",
|
||||||
|
"external/quickjs/",
|
||||||
|
"external/openjpeg/",
|
||||||
|
"test/tmp/",
|
||||||
|
"test/pdfs/",
|
||||||
|
"web/locale/",
|
||||||
|
"**/*~/",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
Base configuration
|
||||||
|
\* ======================================================================== */
|
||||||
|
|
||||||
|
prettierRecommended,
|
||||||
|
{
|
||||||
|
files: ["**/*.json"],
|
||||||
|
...json.configs.recommended,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: jsFiles("."),
|
||||||
|
ignores: chromiumExtensionServiceWorkerFiles,
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.browser,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: jsFiles("."),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
import: import_.flatConfigs.recommended.plugins.import,
|
||||||
|
json,
|
||||||
|
"no-unsanitized": noUnsanitized,
|
||||||
|
perfectionist,
|
||||||
|
unicorn,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.worker,
|
||||||
|
PDFJSDev: "readonly",
|
||||||
|
__non_webpack_import__: "readonly",
|
||||||
|
},
|
||||||
|
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"import/export": "error",
|
||||||
|
"import/exports-last": "error",
|
||||||
|
"import/extensions": ["error", "always", { ignorePackages: true }],
|
||||||
|
"import/first": "error",
|
||||||
|
"import/named": "error",
|
||||||
|
"import/no-cycle": "error",
|
||||||
|
"import/no-empty-named-blocks": "error",
|
||||||
|
"import/no-commonjs": "error",
|
||||||
|
"import/no-mutable-exports": "error",
|
||||||
|
"import/no-self-import": "error",
|
||||||
|
"import/no-unresolved": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
ignore: [
|
||||||
|
"display",
|
||||||
|
"pdfjs",
|
||||||
|
"pdfjs-lib",
|
||||||
|
"pdfjs-web",
|
||||||
|
"web",
|
||||||
|
"fluent-bundle",
|
||||||
|
"fluent-dom",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-unsanitized/method": "error",
|
||||||
|
"no-unsanitized/property": "error",
|
||||||
|
"perfectionist/sort-exports": "error",
|
||||||
|
"perfectionist/sort-named-exports": "error",
|
||||||
|
"unicorn/no-abusive-eslint-disable": "error",
|
||||||
|
"unicorn/no-array-push-push": "error",
|
||||||
|
"unicorn/no-instanceof-array": "error",
|
||||||
|
"unicorn/no-invalid-remove-event-listener": "error",
|
||||||
|
"unicorn/no-new-buffer": "error",
|
||||||
|
"unicorn/no-typeof-undefined": ["error", { checkGlobalVariables: false }],
|
||||||
|
"unicorn/no-useless-promise-resolve-reject": "error",
|
||||||
|
"unicorn/no-useless-spread": "error",
|
||||||
|
"unicorn/prefer-array-find": "error",
|
||||||
|
"unicorn/prefer-array-flat": "error",
|
||||||
|
"unicorn/prefer-array-flat-map": "error",
|
||||||
|
"unicorn/prefer-array-index-of": "error",
|
||||||
|
"unicorn/prefer-array-some": "error",
|
||||||
|
"unicorn/prefer-at": "error",
|
||||||
|
"unicorn/prefer-date-now": "error",
|
||||||
|
"unicorn/prefer-dom-node-append": "error",
|
||||||
|
"unicorn/prefer-dom-node-remove": "error",
|
||||||
|
"unicorn/prefer-includes": "error",
|
||||||
|
"unicorn/prefer-logical-operator-over-ternary": "error",
|
||||||
|
"unicorn/prefer-modern-dom-apis": "error",
|
||||||
|
"unicorn/prefer-modern-math-apis": "error",
|
||||||
|
"unicorn/prefer-negative-index": "error",
|
||||||
|
"unicorn/prefer-optional-catch-binding": "error",
|
||||||
|
"unicorn/prefer-regexp-test": "error",
|
||||||
|
"unicorn/prefer-string-replace-all": "error",
|
||||||
|
"unicorn/prefer-string-starts-ends-with": "error",
|
||||||
|
"unicorn/prefer-ternary": ["error", "only-single-line"],
|
||||||
|
"unicorn/throw-new-error": "error",
|
||||||
|
|
||||||
|
// Possible errors
|
||||||
|
"for-direction": "error",
|
||||||
|
"getter-return": "error",
|
||||||
|
"no-async-promise-executor": "error",
|
||||||
|
"no-cond-assign": ["error", "except-parens"],
|
||||||
|
"no-constant-condition": ["error", { checkLoops: false }],
|
||||||
|
"no-debugger": "error",
|
||||||
|
"no-dupe-args": "error",
|
||||||
|
"no-dupe-else-if": "error",
|
||||||
|
"no-dupe-keys": "error",
|
||||||
|
"no-duplicate-case": "error",
|
||||||
|
"no-empty": ["error", { allowEmptyCatch: true }],
|
||||||
|
"no-empty-character-class": "error",
|
||||||
|
"no-ex-assign": "error",
|
||||||
|
"no-extra-boolean-cast": "error",
|
||||||
|
"no-func-assign": "error",
|
||||||
|
"no-inner-declarations": ["error", "functions"],
|
||||||
|
"no-invalid-regexp": "error",
|
||||||
|
"no-irregular-whitespace": "error",
|
||||||
|
"no-loss-of-precision": "error",
|
||||||
|
"no-obj-calls": "error",
|
||||||
|
"no-promise-executor-return": "error",
|
||||||
|
"no-regex-spaces": "error",
|
||||||
|
"no-setter-return": "error",
|
||||||
|
"no-sparse-arrays": "error",
|
||||||
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-unexpected-multiline": "error",
|
||||||
|
"no-unreachable": "error",
|
||||||
|
"no-unsafe-finally": "error",
|
||||||
|
"no-unsafe-negation": "error",
|
||||||
|
"no-unsafe-optional-chaining": [
|
||||||
|
"error",
|
||||||
|
{ disallowArithmeticOperators: true },
|
||||||
|
],
|
||||||
|
"no-unused-private-class-members": "error",
|
||||||
|
"use-isnan": ["error", { enforceForIndexOf: true }],
|
||||||
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
||||||
|
|
||||||
|
// Best Practices
|
||||||
|
"accessor-pairs": [
|
||||||
|
"error",
|
||||||
|
{ setWithoutGet: true, enforceForClassMembers: true },
|
||||||
|
],
|
||||||
|
"consistent-return": "error",
|
||||||
|
curly: ["error", "all"],
|
||||||
|
"default-case-last": "error",
|
||||||
|
"dot-notation": "error",
|
||||||
|
eqeqeq: ["error", "always"],
|
||||||
|
"grouped-accessor-pairs": ["error", "getBeforeSet"],
|
||||||
|
"no-alert": "error",
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-else-return": "error",
|
||||||
|
"no-empty-pattern": "error",
|
||||||
|
"no-eval": "error",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-extra-label": "error",
|
||||||
|
"no-fallthrough": "error",
|
||||||
|
"no-floating-decimal": "error",
|
||||||
|
"no-global-assign": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-iterator": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-lonely-if": "error",
|
||||||
|
"no-multi-str": "error",
|
||||||
|
"no-new": "error",
|
||||||
|
"no-new-func": "error",
|
||||||
|
"no-new-symbol": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-octal-escape": "error",
|
||||||
|
"no-octal": "error",
|
||||||
|
"no-redeclare": "error",
|
||||||
|
"no-return-await": "error",
|
||||||
|
"no-self-assign": "error",
|
||||||
|
"no-self-compare": "error",
|
||||||
|
"no-throw-literal": "error",
|
||||||
|
"no-unused-expressions": "error",
|
||||||
|
"no-unused-labels": "error",
|
||||||
|
"no-useless-call": "error",
|
||||||
|
"no-useless-catch": "error",
|
||||||
|
"no-useless-concat": "error",
|
||||||
|
"no-useless-escape": "error",
|
||||||
|
"no-useless-return": "error",
|
||||||
|
"prefer-promise-reject-errors": "error",
|
||||||
|
"prefer-spread": "error",
|
||||||
|
"wrap-iife": ["error", "any"],
|
||||||
|
yoda: ["error", "never", { exceptRange: true }],
|
||||||
|
|
||||||
|
// Strict Mode
|
||||||
|
strict: ["off", "global"],
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
"no-delete-var": "error",
|
||||||
|
"no-label-var": "error",
|
||||||
|
"no-shadow": "error",
|
||||||
|
"no-shadow-restricted-names": "error",
|
||||||
|
"no-undef-init": "error",
|
||||||
|
"no-undef": ["error", { typeof: true }],
|
||||||
|
"no-unused-vars": ["error", { vars: "all", args: "none" }],
|
||||||
|
"no-use-before-define": [
|
||||||
|
"error",
|
||||||
|
{ functions: false, classes: false, variables: false },
|
||||||
|
],
|
||||||
|
|
||||||
|
// Stylistic Issues
|
||||||
|
"lines-between-class-members": ["error", "always"],
|
||||||
|
"max-len": ["error", { code: 1000, comments: 80, ignoreUrls: true }],
|
||||||
|
"new-cap": ["error", { newIsCap: true, capIsNew: false }],
|
||||||
|
"no-array-constructor": "error",
|
||||||
|
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 0, maxBOF: 1 }],
|
||||||
|
"no-nested-ternary": "error",
|
||||||
|
"no-new-object": "error",
|
||||||
|
"no-restricted-syntax": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
selector:
|
||||||
|
"BinaryExpression[operator='instanceof'][right.name='Object']",
|
||||||
|
message: "Use `typeof` rather than `instanceof Object`.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "CallExpression[callee.name='assert'][arguments.length!=2]",
|
||||||
|
message: "`assert()` must always be invoked with two arguments.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "CallExpression[callee.name='isCmd'][arguments.length<2]",
|
||||||
|
message:
|
||||||
|
"Use `instanceof Cmd` rather than `isCmd()` with one argument.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "CallExpression[callee.name='isDict'][arguments.length<2]",
|
||||||
|
message:
|
||||||
|
"Use `instanceof Dict` rather than `isDict()` with one argument.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "CallExpression[callee.name='isName'][arguments.length<2]",
|
||||||
|
message:
|
||||||
|
"Use `instanceof Name` rather than `isName()` with one argument.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "NewExpression[callee.name='Cmd']",
|
||||||
|
message: "Use `Cmd.get()` rather than `new Cmd()`.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "NewExpression[callee.name='Name']",
|
||||||
|
message: "Use `Name.get()` rather than `new Name()`.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: "NewExpression[callee.name='Ref']",
|
||||||
|
message: "Use `Ref.get()` rather than `new Ref()`.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-unneeded-ternary": "error",
|
||||||
|
"operator-assignment": "error",
|
||||||
|
"prefer-exponentiation-operator": "error",
|
||||||
|
"spaced-comment": ["error", "always", { block: { balanced: true } }],
|
||||||
|
|
||||||
|
// ECMAScript 6
|
||||||
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
|
"constructor-super": "error",
|
||||||
|
"no-class-assign": "error",
|
||||||
|
"no-const-assign": "error",
|
||||||
|
"no-dupe-class-members": "error",
|
||||||
|
"no-duplicate-imports": "error",
|
||||||
|
"no-this-before-super": "error",
|
||||||
|
"no-useless-computed-key": "error",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-useless-rename": "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"object-shorthand": ["error", "always", { avoidQuotes: true }],
|
||||||
|
"prefer-const": "error",
|
||||||
|
"require-yield": "error",
|
||||||
|
"sort-imports": ["error", { ignoreCase: true }],
|
||||||
|
"template-curly-spacing": ["error", "never"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
Test-specific rules
|
||||||
|
\* ======================================================================== */
|
||||||
|
|
||||||
|
{
|
||||||
|
files: jsFiles("test"),
|
||||||
|
|
||||||
|
plugins: { jasmine },
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.jasmine,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...jasmine.configs.recommended.rules,
|
||||||
|
"jasmine/new-line-before-expect": "off",
|
||||||
|
"jasmine/new-line-between-declarations": "off",
|
||||||
|
"jasmine/no-focused-tests": "error",
|
||||||
|
"jasmine/no-pending-tests": "off",
|
||||||
|
"jasmine/no-spec-dupes": ["error", "branch"],
|
||||||
|
"jasmine/no-suite-dupes": ["error", "branch"],
|
||||||
|
"jasmine/prefer-jasmine-matcher": "off",
|
||||||
|
"jasmine/prefer-toHaveBeenCalledWith": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: jsFiles("test/fuzz"),
|
||||||
|
rules: {
|
||||||
|
"import/no-unresolved": [
|
||||||
|
"error",
|
||||||
|
{ ignore: [".*/build/image_decoders/.*"] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: jsFiles("test/unit"),
|
||||||
|
rules: {
|
||||||
|
"import/no-unresolved": ["error", { ignore: ["pdfjs/"] }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: jsFiles("test/integration"),
|
||||||
|
rules: {
|
||||||
|
"no-restricted-syntax": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
selector: "CallExpression[callee.name='waitForTimeout']",
|
||||||
|
message:
|
||||||
|
"`waitForTimeout` can cause intermittent failures and should not be used (see issue #17656 for replacements).",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
External libraries
|
||||||
|
\* ======================================================================== */
|
||||||
|
|
||||||
|
{
|
||||||
|
files: jsFiles("external"),
|
||||||
|
|
||||||
|
languageOptions: { globals: globals.node },
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
Examples
|
||||||
|
\* ======================================================================== */
|
||||||
|
|
||||||
|
{
|
||||||
|
files: jsFiles("examples"),
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
pdfjsImageDecoders: false,
|
||||||
|
pdfjsLib: false,
|
||||||
|
pdfjsViewer: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: [...jsFiles("examples/node"), ...jsFiles("examples/webpack")],
|
||||||
|
|
||||||
|
languageOptions: { globals: globals.node },
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
Chromium extension
|
||||||
|
\* ======================================================================== */
|
||||||
|
|
||||||
|
{
|
||||||
|
files: jsFiles("extensions/chromium"),
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.webextensions,
|
||||||
|
sourceType: "script",
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"no-var": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: chromiumExtensionServiceWorkerFiles,
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: globals.serviceworker,
|
||||||
|
sourceType: "script",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ======================================================================== *\
|
||||||
|
Other
|
||||||
|
\* ======================================================================== */
|
||||||
|
{
|
||||||
|
files: ["gulpfile.mjs"],
|
||||||
|
languageOptions: { globals: globals.node },
|
||||||
|
},
|
||||||
|
];
|
||||||
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"pdfjsImageDecoders": false,
|
|
||||||
"pdfjsLib": false,
|
|
||||||
"pdfjsViewer": false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
9
external/.eslintrc
vendored
9
external/.eslintrc
vendored
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
../.eslintrc
|
|
||||||
],
|
|
||||||
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -12,7 +12,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* eslint-env node */
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
babelPluginPDFJSPreprocessor,
|
babelPluginPDFJSPreprocessor,
|
||||||
@ -1956,8 +1955,6 @@ gulp.task("lint", function (done) {
|
|||||||
// Ensure that we lint the Firefox specific *.jsm files too.
|
// Ensure that we lint the Firefox specific *.jsm files too.
|
||||||
const esLintOptions = [
|
const esLintOptions = [
|
||||||
"node_modules/eslint/bin/eslint",
|
"node_modules/eslint/bin/eslint",
|
||||||
"--ext",
|
|
||||||
".js,.jsm,.mjs,.json",
|
|
||||||
".",
|
".",
|
||||||
"--report-unused-disable-directives",
|
"--report-unused-disable-directives",
|
||||||
];
|
];
|
||||||
|
|||||||
18
package-lock.json
generated
18
package-lock.json
generated
@ -24,11 +24,12 @@
|
|||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jasmine": "^4.2.2",
|
"eslint-plugin-jasmine": "^4.2.2",
|
||||||
"eslint-plugin-json": "^3.1.0",
|
"eslint-plugin-json": "^4.0.1",
|
||||||
"eslint-plugin-no-unsanitized": "^4.1.2",
|
"eslint-plugin-no-unsanitized": "^4.1.2",
|
||||||
"eslint-plugin-perfectionist": "^3.9.1",
|
"eslint-plugin-perfectionist": "^3.9.1",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"eslint-plugin-unicorn": "^56.0.0",
|
"eslint-plugin-unicorn": "^56.0.0",
|
||||||
|
"globals": "^15.12.0",
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-cli": "^3.0.0",
|
"gulp-cli": "^3.0.0",
|
||||||
"gulp-postcss": "^10.0.0",
|
"gulp-postcss": "^10.0.0",
|
||||||
@ -5454,16 +5455,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-json": {
|
"node_modules/eslint-plugin-json": {
|
||||||
"version": "3.1.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-json/-/eslint-plugin-json-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-json/-/eslint-plugin-json-4.0.1.tgz",
|
||||||
"integrity": "sha512-MrlG2ynFEHe7wDGwbUuFPsaT2b1uhuEFhJ+W1f1u+1C2EkXmTYJp4B1aAdQQ8M+CC3t//N/oRKiIVw14L2HR1g==",
|
"integrity": "sha512-3An5ISV5dq/kHfXdNyY5TUe2ONC3yXFSkLX2gu+W8xAhKhfvrRvkSAeKXCxZqZ0KJLX15ojBuLPyj+UikQMkOA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"vscode-json-languageservice": "^4.1.6"
|
"vscode-json-languageservice": "^4.1.6"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0"
|
"node": ">=18.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-no-unsanitized": {
|
"node_modules/eslint-plugin-no-unsanitized": {
|
||||||
@ -6967,9 +6969,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/globals": {
|
"node_modules/globals": {
|
||||||
"version": "15.10.0",
|
"version": "15.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/globals/-/globals-15.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz",
|
||||||
"integrity": "sha512-tqFIbz83w4Y5TCbtgjZjApohbuh7K9BxGYFm7ifwDR240tvdb7P9x+/9VvUKlmkPoiknoJtanI8UOrqxS3a7lQ==",
|
"integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@ -19,11 +19,12 @@
|
|||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jasmine": "^4.2.2",
|
"eslint-plugin-jasmine": "^4.2.2",
|
||||||
"eslint-plugin-json": "^3.1.0",
|
"eslint-plugin-json": "^4.0.1",
|
||||||
"eslint-plugin-no-unsanitized": "^4.1.2",
|
"eslint-plugin-no-unsanitized": "^4.1.2",
|
||||||
"eslint-plugin-perfectionist": "^3.9.1",
|
"eslint-plugin-perfectionist": "^3.9.1",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"eslint-plugin-unicorn": "^56.0.0",
|
"eslint-plugin-unicorn": "^56.0.0",
|
||||||
|
"globals": "^15.12.0",
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-cli": "^3.0.0",
|
"gulp-cli": "^3.0.0",
|
||||||
"gulp-postcss": "^10.0.0",
|
"gulp-postcss": "^10.0.0",
|
||||||
|
|||||||
@ -48,11 +48,9 @@ class ImageResizer {
|
|||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
"canUseImageDecoder",
|
"canUseImageDecoder",
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
this.#isChrome || typeof ImageDecoder === "undefined"
|
this.#isChrome || typeof ImageDecoder === "undefined"
|
||||||
? Promise.resolve(false)
|
? Promise.resolve(false)
|
||||||
: // eslint-disable-next-line no-undef
|
: ImageDecoder.isTypeSupported("image/bmp")
|
||||||
ImageDecoder.isTypeSupported("image/bmp")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +183,6 @@ class ImageResizer {
|
|||||||
let decoder, imagePromise;
|
let decoder, imagePromise;
|
||||||
|
|
||||||
if (await ImageResizer.canUseImageDecoder) {
|
if (await ImageResizer.canUseImageDecoder) {
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
decoder = new ImageDecoder({
|
decoder = new ImageDecoder({
|
||||||
data,
|
data,
|
||||||
type: "image/bmp",
|
type: "image/bmp",
|
||||||
|
|||||||
@ -36,11 +36,9 @@ class JpegStream extends DecodeStream {
|
|||||||
return shadow(
|
return shadow(
|
||||||
this,
|
this,
|
||||||
"canUseImageDecoder",
|
"canUseImageDecoder",
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
typeof ImageDecoder === "undefined"
|
typeof ImageDecoder === "undefined"
|
||||||
? Promise.resolve(false)
|
? Promise.resolve(false)
|
||||||
: // eslint-disable-next-line no-undef
|
: ImageDecoder.isTypeSupported("image/jpeg")
|
||||||
ImageDecoder.isTypeSupported("image/jpeg")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +161,6 @@ class JpegStream extends DecodeStream {
|
|||||||
if (!JpegImage.canUseImageDecoder(data, jpegOptions.colorTransform)) {
|
if (!JpegImage.canUseImageDecoder(data, jpegOptions.colorTransform)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
decoder = new ImageDecoder({
|
decoder = new ImageDecoder({
|
||||||
data,
|
data,
|
||||||
type: "image/jpeg",
|
type: "image/jpeg",
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["jasmine"],
|
|
||||||
"extends": ["../.eslintrc", "plugin:jasmine/recommended"],
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"jasmine": true
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"jasmine/new-line-before-expect": "off",
|
|
||||||
"jasmine/new-line-between-declarations": "off",
|
|
||||||
"jasmine/no-focused-tests": "error",
|
|
||||||
"jasmine/no-pending-tests": "off",
|
|
||||||
"jasmine/no-spec-dupes": ["error", "branch"],
|
|
||||||
"jasmine/no-suite-dupes": ["error", "branch"],
|
|
||||||
"jasmine/prefer-jasmine-matcher": "off",
|
|
||||||
"jasmine/prefer-toHaveBeenCalledWith": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"rules": {
|
|
||||||
"import/no-unresolved": ["error", { "ignore": [".*/build/image_decoders/.*"] }],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"rules": {
|
|
||||||
"no-restricted-syntax": ["error",
|
|
||||||
{
|
|
||||||
"selector": "CallExpression[callee.name='waitForTimeout']",
|
|
||||||
"message": "`waitForTimeout` can cause intermittent failures and should not be used (see issue #17656 for replacements).",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"../.eslintrc"
|
|
||||||
],
|
|
||||||
|
|
||||||
"rules": {
|
|
||||||
// Plugins
|
|
||||||
"import/no-unresolved": ["error", { "ignore": ["pdfjs/"] }],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user