Skip to content

Commit f5f77ff

Browse files
committed
Fix ESLint errors
1 parent 1bc1399 commit f5f77ff

File tree

20 files changed

+110
-108
lines changed

20 files changed

+110
-108
lines changed

src/bidi.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Bidi.prototype.registerFeatures = function (script, tags) {
8787
const supportedTags = tags.filter(
8888
tag => this.query.supports({script, tag})
8989
);
90-
if (!this.featuresTags.hasOwnProperty(script)) {
90+
if (!Object.prototype.hasOwnProperty.call(this.featuresTags, script)) {
9191
this.featuresTags[script] = supportedTags;
9292
} else {
9393
this.featuresTags[script] =
@@ -140,7 +140,7 @@ function checkGlyphIndexStatus() {
140140
*/
141141
function applyArabicPresentationForms() {
142142
const script = 'arab';
143-
if (!this.featuresTags.hasOwnProperty(script)) return;
143+
if (!Object.prototype.hasOwnProperty.call(this.featuresTags, script)) return;
144144
checkGlyphIndexStatus.call(this);
145145
const ranges = this.tokenizer.getContextRanges('arabicWord');
146146
ranges.forEach(range => {
@@ -153,7 +153,7 @@ function applyArabicPresentationForms() {
153153
*/
154154
function applyArabicRequireLigatures() {
155155
const script = 'arab';
156-
if (!this.featuresTags.hasOwnProperty(script)) return;
156+
if (!Object.prototype.hasOwnProperty.call(this.featuresTags, script)) return;
157157
const tags = this.featuresTags[script];
158158
if (tags.indexOf('rlig') === -1) return;
159159
checkGlyphIndexStatus.call(this);
@@ -168,7 +168,7 @@ function applyArabicRequireLigatures() {
168168
*/
169169
function applyLatinLigatures() {
170170
const script = 'latn';
171-
if (!this.featuresTags.hasOwnProperty(script)) return;
171+
if (!Object.prototype.hasOwnProperty.call(this.featuresTags, script)) return;
172172
const tags = this.featuresTags[script];
173173
if (tags.indexOf('liga') === -1) return;
174174
checkGlyphIndexStatus.call(this);

src/char.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export function isIsolatedArabicChar(char) {
2323
* @param {string} c a single char
2424
*/
2525
export function isTashkeelArabicChar(char) {
26+
// eslint-disable-next-line no-misleading-character-class
2627
return /[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(char);
2728
}
2829

src/features/arab/arabicPresentationForms.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function arabicPresentationForms(range) {
4848
if (tokens.length === 1) return;
4949
let contextParams = new ContextParams(
5050
tokens.map(token => token.getState('glyphIndex')
51-
), 0);
51+
), 0);
5252
const charContextParams = new ContextParams(
5353
tokens.map(token => token.char
54-
), 0);
54+
), 0);
5555
tokens.forEach((token, index) => {
5656
if (isTashkeelArabicChar(token.char)) return;
5757
contextParams.setCurrentIndex(index);

src/features/arab/contextCheck/arabicSentence.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function arabicSentenceEndCheck(contextParams) {
1919
switch (true) {
2020
case nextChar === null:
2121
return true;
22-
case (!isArabicChar(nextChar) && !isTashkeelArabicChar(nextChar)):
22+
case (!isArabicChar(nextChar) && !isTashkeelArabicChar(nextChar)): {
2323
const nextIsWhitespace = isWhiteSpace(nextChar);
2424
if (!nextIsWhitespace) return true;
2525
if (nextIsWhitespace) {
@@ -32,6 +32,7 @@ function arabicSentenceEndCheck(contextParams) {
3232
if (!arabicCharAhead) return true;
3333
}
3434
break;
35+
}
3536
default:
3637
return false;
3738
}

src/features/featureQuery.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function lookupCoverage(glyphIndex, coverage) {
4343
case 1:
4444
return coverage.glyphs.indexOf(glyphIndex);
4545

46-
case 2:
46+
case 2: {
4747
let ranges = coverage.ranges;
4848
for (let i = 0; i < ranges.length; i++) {
4949
const range = ranges[i];
@@ -53,6 +53,7 @@ function lookupCoverage(glyphIndex, coverage) {
5353
}
5454
}
5555
break;
56+
}
5657
default:
5758
return -1; // not found
5859
}
@@ -230,7 +231,7 @@ FeatureQuery.prototype.getScriptFeaturesIndexes = function(scriptTag) {
230231
return script.script.defaultLangSys.featureIndexes;
231232
} else {
232233
let langSysRecords = script.langSysRecords;
233-
if (!!langSysRecords) {
234+
if (langSysRecords) {
234235
for (let j = 0; j < langSysRecords.length; j++) {
235236
const langSysRecord = langSysRecords[j];
236237
if (langSysRecord.tag === scriptTag) {
@@ -265,7 +266,7 @@ FeatureQuery.prototype.mapTagsToFeatures = function (features, scriptTag) {
265266
*/
266267
FeatureQuery.prototype.getScriptFeatures = function (scriptTag) {
267268
let features = this.features[scriptTag];
268-
if (this.features.hasOwnProperty(scriptTag)) return features;
269+
if (Object.prototype.hasOwnProperty.call(this.features, scriptTag)) return features;
269270
const featuresIndexes = this.getScriptFeaturesIndexes(scriptTag);
270271
if (!featuresIndexes) return null;
271272
const gsub = this.font.tables.gsub;
@@ -318,7 +319,7 @@ FeatureQuery.prototype.getLookupMethod = function(lookupTable, subtable) {
318319
throw new Error(
319320
`lookupType: ${lookupTable.lookupType} - ` +
320321
`substFormat: ${subtable.substFormat} ` +
321-
`is not yet supported`
322+
'is not yet supported'
322323
);
323324
}
324325
};
@@ -428,7 +429,7 @@ FeatureQuery.prototype.lookupFeature = function (query) {
428429
FeatureQuery.prototype.supports = function (query) {
429430
if (!query.script) return false;
430431
this.getScriptFeatures(query.script);
431-
const supportedScript = this.features.hasOwnProperty(query.script);
432+
const supportedScript = Object.prototype.hasOwnProperty.call(this.features, query.script);
432433
if (!query.tag) return supportedScript;
433434
const supportedFeature = (
434435
this.features[query.script].some(feature => feature.tag === query.tag)
@@ -467,8 +468,8 @@ FeatureQuery.prototype.getFeatureLookups = function (feature) {
467468
* @param {any} query an object that describes the properties of a query
468469
*/
469470
FeatureQuery.prototype.getFeature = function getFeature(query) {
470-
if (!this.font) return { FAIL: `No font was found`};
471-
if (!this.features.hasOwnProperty(query.script)) {
471+
if (!this.font) return { FAIL: 'No font was found'};
472+
if (!Object.prototype.hasOwnProperty.call(this.features, query.script)) {
472473
this.getScriptFeatures(query.script);
473474
}
474475
const scriptFeatures = this.features[query.script];

src/font.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function Font(options) {
113113
if (this.outlinesFormat === 'truetype') {
114114
return (this._hinting = new HintingTrueType(this));
115115
}
116+
return null;
116117
}
117118
});
118119
}
@@ -191,8 +192,8 @@ Font.prototype.stringToGlyphIndexes = function(s, options) {
191192

192193
// roll-back to default features
193194
let features = options ?
194-
this.updateFeatures(options.features) :
195-
this.defaultRenderOptions.features;
195+
this.updateFeatures(options.features) :
196+
this.defaultRenderOptions.features;
196197

197198
bidi.applyFeatures(this, features);
198199

@@ -335,8 +336,8 @@ Font.prototype.forEachGlyph = function(text, x, y, fontSize, options, callback)
335336
// We should apply position adjustment lookups in a more generic way.
336337
// Here we only use the xAdvance value.
337338
const kerningValue = kerningLookups ?
338-
this.position.getKerningValue(kerningLookups, glyph.index, glyphs[i + 1].index) :
339-
this.getKerningValue(glyph, glyphs[i + 1]);
339+
this.position.getKerningValue(kerningLookups, glyph.index, glyphs[i + 1].index) :
340+
this.getKerningValue(glyph, glyphs[i + 1]);
340341
x += kerningValue * fontScale;
341342
}
342343

@@ -479,7 +480,7 @@ Font.prototype.validate = function() {
479480
function assertNamePresent(name) {
480481
const englishName = _this.getEnglishName(name);
481482
assert(englishName && englishName.trim().length > 0,
482-
'No English ' + name + ' specified.');
483+
'No English ' + name + ' specified.');
483484
}
484485

485486
// Identification information
@@ -553,7 +554,7 @@ Font.prototype.download = function(fileName) {
553554
} else {
554555
const fs = require('fs');
555556
const buffer = Buffer.alloc(arrayBuffer.byteLength);
556-
const view = new Uint8Array(ab);
557+
const view = new Uint8Array(arrayBuffer);
557558
for (let i = 0; i < buffer.length; ++i) {
558559
buffer[i] = view[i];
559560
}

src/glyph.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ Glyph.prototype.getPath = function(x, y, fontSize, options, font) {
177177
p.lineTo(x + (cmd.x * xScale), y + (-cmd.y * yScale));
178178
} else if (cmd.type === 'Q') {
179179
p.quadraticCurveTo(x + (cmd.x1 * xScale), y + (-cmd.y1 * yScale),
180-
x + (cmd.x * xScale), y + (-cmd.y * yScale));
180+
x + (cmd.x * xScale), y + (-cmd.y * yScale));
181181
} else if (cmd.type === 'C') {
182182
p.curveTo(x + (cmd.x1 * xScale), y + (-cmd.y1 * yScale),
183-
x + (cmd.x2 * xScale), y + (-cmd.y2 * yScale),
184-
x + (cmd.x * xScale), y + (-cmd.y * yScale));
183+
x + (cmd.x2 * xScale), y + (-cmd.y2 * yScale),
184+
x + (cmd.x * xScale), y + (-cmd.y * yScale));
185185
} else if (cmd.type === 'Z') {
186186
p.closePath();
187187
}

src/hintingtt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,8 @@ function SHP(a, state) {
15161516
console.log(
15171517
state.step,
15181518
(state.loop > 1 ?
1519-
'loop ' + (state.loop - loop) + ': ' :
1520-
''
1519+
'loop ' + (state.loop - loop) + ': ' :
1520+
''
15211521
) +
15221522
'SHP[' + (a ? 'rp1' : 'rp2') + ']', pi
15231523
);

src/layout.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,16 @@ Layout.prototype = {
281281
*/
282282
getGlyphClass: function(classDefTable, glyphIndex) {
283283
switch (classDefTable.format) {
284-
case 1:
284+
case 1: {
285285
if (classDefTable.startGlyph <= glyphIndex && glyphIndex < classDefTable.startGlyph + classDefTable.classes.length) {
286286
return classDefTable.classes[glyphIndex - classDefTable.startGlyph];
287287
}
288288
return 0;
289-
case 2:
289+
}
290+
case 2: {
290291
const range = searchRange(classDefTable.ranges, glyphIndex);
291292
return range ? range.classId : 0;
293+
}
292294
}
293295
},
294296

@@ -301,12 +303,14 @@ Layout.prototype = {
301303
*/
302304
getCoverageIndex: function(coverageTable, glyphIndex) {
303305
switch (coverageTable.format) {
304-
case 1:
306+
case 1: {
305307
const index = binSearch(coverageTable.glyphs, glyphIndex);
306308
return index >= 0 ? index : -1;
307-
case 2:
309+
}
310+
case 2: {
308311
const range = searchRange(coverageTable.ranges, glyphIndex);
309312
return range ? range.index + glyphIndex - range.start : -1;
313+
}
310314
}
311315
},
312316

src/position.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Position.prototype.getKerningValue = function(kerningLookups, leftIndex, rightIn
3939
const covIndex = this.getCoverageIndex(subtable.coverage, leftIndex);
4040
if (covIndex < 0) continue;
4141
switch (subtable.posFormat) {
42-
case 1:
42+
case 1: {
4343
// Search Pair Adjustment Positioning Format 1
4444
let pairSet = subtable.pairSets[covIndex];
4545
for (let k = 0; k < pairSet.length; k++) {
@@ -49,12 +49,14 @@ Position.prototype.getKerningValue = function(kerningLookups, leftIndex, rightIn
4949
}
5050
}
5151
break; // left glyph found, not right glyph - try next subtable
52-
case 2:
52+
}
53+
case 2: {
5354
// Search Pair Adjustment Positioning Format 2
5455
const class1 = this.getGlyphClass(subtable.classDef1, leftIndex);
5556
const class2 = this.getGlyphClass(subtable.classDef2, rightIndex);
5657
const pair = subtable.classRecords[class1][class2];
5758
return pair.value1 && pair.value1.xAdvance || 0;
59+
}
5860
}
5961
}
6062
}

0 commit comments

Comments
 (0)