Skip to content

Commit bbdf640

Browse files
authored
Merge pull request #1163 from mathjax/linting/new_issues
Lints new issues
2 parents c888ad5 + c922b25 commit bbdf640

14 files changed

Lines changed: 19 additions & 14 deletions

File tree

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default tseslint.config({
1919
files: ['ts/**/*.ts'],
2020
ignores: ["**/*.d.ts", "**/*.js", "**/cjs/*"],
2121
"rules": {
22+
"@typescript-eslint/prefer-includes": "error",
2223
"@typescript-eslint/no-explicit-any": "off",
2324
"@typescript-eslint/no-unused-vars": ["error",
2425
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_",

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"scripts": {
6969
"=============================================================================== code hygene": "",
7070
"lint": "eslint ts/",
71-
"lint:fix": "eslint --fix ts/",
71+
"lint:fix": "eslint --fix ts/ --format unix",
7272
"format": "prettier --check \"ts/**/*.{ts,tsx}\"",
7373
"format:fix": "prettier --write \"ts/**/*.{ts,tsx}\"",
7474
"=============================================================================== clean": "",
@@ -149,7 +149,8 @@
149149
},
150150
"lint-staged": {
151151
"ts/**/*.ts": [
152-
"pnpm format:fix"
152+
"pnpm format:fix",
153+
"pnpm lint:fix"
153154
]
154155
},
155156
"dependencies": {

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export class SpeechExplorer
518518
);
519519
while (internal && internal !== this.generators.element) {
520520
const sid = internal.getAttribute('data-semantic-id');
521-
if (dummies.indexOf(sid) !== -1) {
521+
if (dummies.includes(sid)) {
522522
this.current = this.node.querySelector(
523523
`[data-semantic-id="${sid}"]`
524524
);

ts/adaptors/HTMLAdaptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export class HTMLAdaptor<
514514
if (node.classList) {
515515
return node.classList.contains(name);
516516
}
517-
return node.className.split(/ /).indexOf(name) >= 0;
517+
return node.className.split(/ /).includes(name);
518518
}
519519

520520
/**

ts/components/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class Package {
226226
//
227227
for (const dependent of dependencies) {
228228
const extension = map.get(dependent) || new Package(dependent, noLoad);
229-
if (this.dependencies.indexOf(extension) < 0) {
229+
if (!this.dependencies.includes(extension)) {
230230
extension.addDependent(this, noLoad);
231231
this.dependencies.push(extension);
232232
if (!extension.isLoaded) {

ts/input/tex/Configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export class ParserConfiguration {
436436
*/
437437
protected getPackage(name: string): Configuration {
438438
const config = ConfigurationHandler.get(name);
439-
if (config && this.parsers.indexOf(config.parser) < 0) {
439+
if (config && !this.parsers.includes(config.parser)) {
440440
throw Error(`Package ${name} doesn't target the proper parser`);
441441
}
442442
return config;

ts/input/tex/FilterUtil.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ const FilterUtil = {
316316

317317
/**
318318
* Removes unneeded mstyle elements that just set the scriptlevel
319+
*
320+
* @param {object} arg The argument object.
321+
* @param {ParseOptions} arg.data The parse options.
319322
*/
320323
checkScriptlevel(arg: { data: ParseOptions }) {
321324
const options = arg.data;

ts/input/tex/ParseUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const KeyValueTypes: {
8080
oneof: (...values: string[]) =>
8181
new KeyValueType<string>(
8282
'oneof',
83-
(value) => values.indexOf(value) >= 0,
83+
(value) => values.includes(value),
8484
(value) => value
8585
),
8686
dimen: new KeyValueType<string>(
@@ -191,7 +191,7 @@ function readValue(
191191
countBraces = false; // Stop counting start left braces.
192192
break;
193193
default:
194-
if (!braces && end.indexOf(c) !== -1) {
194+
if (!braces && end.includes(c)) {
195195
// End character reached.
196196
return [
197197
removeBraces(value, l3keys ? Math.min(1, start) : start),

ts/input/tex/bussproofs/BussproofsMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function parseFCenterLine(parser: TexParser, name: string): MmlNode {
144144
}
145145
parser.i++;
146146
const axiom = parser.GetUpTo(name, '$');
147-
if (axiom.indexOf('\\fCenter') === -1) {
147+
if (!axiom.includes('\\fCenter')) {
148148
throw new TexError(
149149
'MissingProofCommand',
150150
'Missing %1 in %2.',

ts/input/tex/newcommand/NewcommandMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ const NewcommandMethods: { [key: string]: ParseMethod } = {
262262
(parser.stack.global['beginEnv'] as number)--;
263263
if (edef) {
264264
// Parse the commands in the end environment definition.
265-
let rest = parser.string.slice(parser.i);
265+
const rest = parser.string.slice(parser.i);
266266
parser.string = ParseUtil.addArgs(
267267
parser,
268268
parser.string.substring(0, parser.i),

0 commit comments

Comments
 (0)