mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes). Prettier is being used for a couple of reasons: - To be consistent with `mozilla-central`, where Prettier is already in use across the tree. - To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters. Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some). Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long. *Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit. (On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
This commit is contained in:
parent
8ec1dfde49
commit
de36b2aaba
205 changed files with 40024 additions and 31859 deletions
|
@ -25,46 +25,54 @@ const CharacterType = {
|
|||
};
|
||||
|
||||
function isAlphabeticalScript(charCode) {
|
||||
return charCode < 0x2E80;
|
||||
return charCode < 0x2e80;
|
||||
}
|
||||
|
||||
function isAscii(charCode) {
|
||||
return (charCode & 0xFF80) === 0;
|
||||
return (charCode & 0xff80) === 0;
|
||||
}
|
||||
|
||||
function isAsciiAlpha(charCode) {
|
||||
return (charCode >= /* a = */ 0x61 && charCode <= /* z = */ 0x7A) ||
|
||||
(charCode >= /* A = */ 0x41 && charCode <= /* Z = */ 0x5A);
|
||||
return (
|
||||
(charCode >= /* a = */ 0x61 && charCode <= /* z = */ 0x7a) ||
|
||||
(charCode >= /* A = */ 0x41 && charCode <= /* Z = */ 0x5a)
|
||||
);
|
||||
}
|
||||
|
||||
function isAsciiDigit(charCode) {
|
||||
return (charCode >= /* 0 = */ 0x30 && charCode <= /* 9 = */ 0x39);
|
||||
return charCode >= /* 0 = */ 0x30 && charCode <= /* 9 = */ 0x39;
|
||||
}
|
||||
|
||||
function isAsciiSpace(charCode) {
|
||||
return (charCode === /* SPACE = */ 0x20 || charCode === /* TAB = */ 0x09 ||
|
||||
charCode === /* CR = */ 0x0D || charCode === /* LF = */ 0x0A);
|
||||
return (
|
||||
charCode === /* SPACE = */ 0x20 ||
|
||||
charCode === /* TAB = */ 0x09 ||
|
||||
charCode === /* CR = */ 0x0d ||
|
||||
charCode === /* LF = */ 0x0a
|
||||
);
|
||||
}
|
||||
|
||||
function isHan(charCode) {
|
||||
return (charCode >= 0x3400 && charCode <= 0x9FFF) ||
|
||||
(charCode >= 0xF900 && charCode <= 0xFAFF);
|
||||
return (
|
||||
(charCode >= 0x3400 && charCode <= 0x9fff) ||
|
||||
(charCode >= 0xf900 && charCode <= 0xfaff)
|
||||
);
|
||||
}
|
||||
|
||||
function isKatakana(charCode) {
|
||||
return (charCode >= 0x30A0 && charCode <= 0x30FF);
|
||||
return charCode >= 0x30a0 && charCode <= 0x30ff;
|
||||
}
|
||||
|
||||
function isHiragana(charCode) {
|
||||
return (charCode >= 0x3040 && charCode <= 0x309F);
|
||||
return charCode >= 0x3040 && charCode <= 0x309f;
|
||||
}
|
||||
|
||||
function isHalfwidthKatakana(charCode) {
|
||||
return (charCode >= 0xFF60 && charCode <= 0xFF9F);
|
||||
return charCode >= 0xff60 && charCode <= 0xff9f;
|
||||
}
|
||||
|
||||
function isThai(charCode) {
|
||||
return (charCode & 0xFF80) === 0x0E00;
|
||||
return (charCode & 0xff80) === 0x0e00;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,14 +84,17 @@ function getCharacterType(charCode) {
|
|||
if (isAscii(charCode)) {
|
||||
if (isAsciiSpace(charCode)) {
|
||||
return CharacterType.SPACE;
|
||||
} else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) ||
|
||||
charCode === /* UNDERSCORE = */ 0x5F) {
|
||||
} else if (
|
||||
isAsciiAlpha(charCode) ||
|
||||
isAsciiDigit(charCode) ||
|
||||
charCode === /* UNDERSCORE = */ 0x5f
|
||||
) {
|
||||
return CharacterType.ALPHA_LETTER;
|
||||
}
|
||||
return CharacterType.PUNCT;
|
||||
} else if (isThai(charCode)) {
|
||||
return CharacterType.THAI_LETTER;
|
||||
} else if (charCode === /* NBSP = */ 0xA0) {
|
||||
} else if (charCode === /* NBSP = */ 0xa0) {
|
||||
return CharacterType.SPACE;
|
||||
}
|
||||
return CharacterType.ALPHA_LETTER;
|
||||
|
@ -101,7 +112,4 @@ function getCharacterType(charCode) {
|
|||
return CharacterType.ALPHA_LETTER;
|
||||
}
|
||||
|
||||
export {
|
||||
CharacterType,
|
||||
getCharacterType,
|
||||
};
|
||||
export { CharacterType, getCharacterType };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue