Remove helpers.utf8Encoding because it annoys the latest TypeScript compiler.

This commit is contained in:
David Anson 2021-08-05 22:01:29 -07:00
parent 752e7141c8
commit b10147f16b
3 changed files with 8 additions and 13 deletions

View file

@ -55,8 +55,6 @@ var linkRe = /(\[(?:[^[\]]|\[[^\]]*\])*\])(\(\S*\)|\[\S*\])?/g;
module.exports.linkRe = linkRe; module.exports.linkRe = linkRe;
// Regular expression for link reference definition lines // Regular expression for link reference definition lines
module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/; module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/;
// readFile options for reading with the UTF-8 encoding
module.exports.utf8Encoding = "utf8";
// All punctuation characters (normal and full-width) // All punctuation characters (normal and full-width)
var allPunctuation = ".,;:!?。,;:!?"; var allPunctuation = ".,;:!?。,;:!?";
module.exports.allPunctuation = allPunctuation; module.exports.allPunctuation = allPunctuation;
@ -1463,10 +1461,10 @@ function lintFile(ruleList, file, md, config, frontMatter, handleRuleFailures, n
// Make a/synchronous call to read file // Make a/synchronous call to read file
if (synchronous) { if (synchronous) {
// @ts-ignore // @ts-ignore
lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding)); lintContentWrapper(null, fs.readFileSync(file, "utf8"));
} }
else { else {
fs.readFile(file, helpers.utf8Encoding, lintContentWrapper); fs.readFile(file, "utf8", lintContentWrapper);
} }
} }
/** /**
@ -1683,7 +1681,7 @@ function readConfig(file, parsers, callback) {
parsers = null; parsers = null;
} }
// Read file // Read file
fs.readFile(file, helpers.utf8Encoding, function (err, content) { fs.readFile(file, "utf8", function (err, content) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -1730,7 +1728,7 @@ function readConfigPromise(file, parsers) {
function readConfigSync(file, parsers) { function readConfigSync(file, parsers) {
// Read file // Read file
// @ts-ignore // @ts-ignore
var content = fs.readFileSync(file, helpers.utf8Encoding); var content = fs.readFileSync(file, "utf8");
// Try to parse file // Try to parse file
var _a = parseConfiguration(file, content, parsers), config = _a.config, message = _a.message; var _a = parseConfiguration(file, content, parsers), config = _a.config, message = _a.message;
if (!config) { if (!config) {

View file

@ -35,9 +35,6 @@ module.exports.linkRe = linkRe;
// Regular expression for link reference definition lines // Regular expression for link reference definition lines
module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/; module.exports.linkReferenceRe = /^ {0,3}\[[^\]]+]:\s.*$/;
// readFile options for reading with the UTF-8 encoding
module.exports.utf8Encoding = "utf8";
// All punctuation characters (normal and full-width) // All punctuation characters (normal and full-width)
const allPunctuation = ".,;:!?。,;:!?"; const allPunctuation = ".,;:!?。,;:!?";
module.exports.allPunctuation = allPunctuation; module.exports.allPunctuation = allPunctuation;

View file

@ -711,9 +711,9 @@ function lintFile(
// Make a/synchronous call to read file // Make a/synchronous call to read file
if (synchronous) { if (synchronous) {
// @ts-ignore // @ts-ignore
lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding)); lintContentWrapper(null, fs.readFileSync(file, "utf8"));
} else { } else {
fs.readFile(file, helpers.utf8Encoding, lintContentWrapper); fs.readFile(file, "utf8", lintContentWrapper);
} }
} }
@ -968,7 +968,7 @@ function readConfig(file, parsers, callback) {
parsers = null; parsers = null;
} }
// Read file // Read file
fs.readFile(file, helpers.utf8Encoding, (err, content) => { fs.readFile(file, "utf8", (err, content) => {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -1021,7 +1021,7 @@ function readConfigPromise(file, parsers) {
function readConfigSync(file, parsers) { function readConfigSync(file, parsers) {
// Read file // Read file
// @ts-ignore // @ts-ignore
const content = fs.readFileSync(file, helpers.utf8Encoding); const content = fs.readFileSync(file, "utf8");
// Try to parse file // Try to parse file
const { config, message } = parseConfiguration(file, content, parsers); const { config, message } = parseConfiguration(file, content, parsers);
if (!config) { if (!config) {