Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lints new issues #1163

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default tseslint.config({
files: ['ts/**/*.ts'],
ignores: ["**/*.d.ts", "**/*.js", "**/cjs/*"],
"rules": {
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": ["error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"scripts": {
"=============================================================================== code hygene": "",
"lint": "eslint ts/",
"lint:fix": "eslint --fix ts/",
"lint:fix": "eslint --fix ts/ --format unix",
"format": "prettier --check \"ts/**/*.{ts,tsx}\"",
"format:fix": "prettier --write \"ts/**/*.{ts,tsx}\"",
"=============================================================================== clean": "",
Expand Down Expand Up @@ -148,7 +148,8 @@
},
"lint-staged": {
"ts/**/*.ts": [
"pnpm format:fix"
"pnpm format:fix",
"pnpm lint:fix"
]
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/explorer/KeyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export class SpeechExplorer
);
while (internal && internal !== this.generators.element) {
const sid = internal.getAttribute('data-semantic-id');
if (dummies.indexOf(sid) !== -1) {
if (dummies.includes(sid)) {
this.current = this.node.querySelector(
`[data-semantic-id="${sid}"]`
);
Expand Down
2 changes: 1 addition & 1 deletion ts/adaptors/HTMLAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export class HTMLAdaptor<
if (node.classList) {
return node.classList.contains(name);
}
return node.className.split(/ /).indexOf(name) >= 0;
return node.className.split(/ /).includes(name);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ts/components/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class Package {
//
for (const dependent of dependencies) {
const extension = map.get(dependent) || new Package(dependent, noLoad);
if (this.dependencies.indexOf(extension) < 0) {
if (!this.dependencies.includes(extension)) {
extension.addDependent(this, noLoad);
this.dependencies.push(extension);
if (!extension.isLoaded) {
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export class ParserConfiguration {
*/
protected getPackage(name: string): Configuration {
const config = ConfigurationHandler.get(name);
if (config && this.parsers.indexOf(config.parser) < 0) {
if (config && !this.parsers.includes(config.parser)) {
throw Error(`Package ${name} doesn't target the proper parser`);
}
return config;
Expand Down
3 changes: 3 additions & 0 deletions ts/input/tex/FilterUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ const FilterUtil = {

/**
* Removes unneeded mstyle elements that just set the scriptlevel
*
* @param {object} arg The argument object.
* @param {ParseOptions} arg.data The parse options.
*/
checkScriptlevel(arg: { data: ParseOptions }) {
const options = arg.data;
Expand Down
4 changes: 2 additions & 2 deletions ts/input/tex/ParseUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const KeyValueTypes: {
oneof: (...values: string[]) =>
new KeyValueType<string>(
'oneof',
(value) => values.indexOf(value) >= 0,
(value) => values.includes(value),
(value) => value
),
dimen: new KeyValueType<string>(
Expand Down Expand Up @@ -191,7 +191,7 @@ function readValue(
countBraces = false; // Stop counting start left braces.
break;
default:
if (!braces && end.indexOf(c) !== -1) {
if (!braces && end.includes(c)) {
// End character reached.
return [
removeBraces(value, l3keys ? Math.min(1, start) : start),
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/bussproofs/BussproofsMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function parseFCenterLine(parser: TexParser, name: string): MmlNode {
}
parser.i++;
const axiom = parser.GetUpTo(name, '$');
if (axiom.indexOf('\\fCenter') === -1) {
if (!axiom.includes('\\fCenter')) {
throw new TexError(
'MissingProofCommand',
'Missing %1 in %2.',
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/newcommand/NewcommandMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const NewcommandMethods: { [key: string]: ParseMethod } = {
(parser.stack.global['beginEnv'] as number)--;
if (edef) {
// Parse the commands in the end environment definition.
let rest = parser.string.slice(parser.i);
const rest = parser.string.slice(parser.i);
parser.string = ParseUtil.addArgs(
parser,
parser.string.substring(0, parser.i),
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/physics/PhysicsMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function vectorApplication(
let lfence = '',
rfence = '',
arg = '';
const enlarge = fences.indexOf(left) !== -1;
const enlarge = fences.includes(left);
if (left === '{') {
arg = parser.GetArgument(name);
lfence = enlarge ? '\\left\\{' : '';
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/require/RequireConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function RegisterExtension(jax: TeX<any, any, any>, name: string) {
const required = jax.parseOptions.packageData.get('require')
.required as string[];
const extension = name.substring(require.prefix.length);
if (required.indexOf(extension) < 0) {
if (!required.includes(extension)) {
required.push(extension);
//
// Register any dependencies that were loaded to handle this one,
Expand Down
2 changes: 1 addition & 1 deletion ts/output/common/Wrappers/mtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ export function CommonMtableMixin<
* @override
*/
public getColumnWidthsPercent(swidths: string[]): ColumnWidths {
const hasFit = swidths.indexOf('fit') >= 0;
const hasFit = swidths.includes('fit');
const { W } = hasFit ? this.getTableData() : { W: null };
return Array.from(swidths.keys()).map((i) => {
const x = swidths[i];
Expand Down
2 changes: 1 addition & 1 deletion ts/ui/menu/AnnotationMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function annotationMatch(
): string | null {
const encoding = child.attributes.get('encoding') as string;
for (const type of Object.keys(types)) {
if (types[type].indexOf(encoding) >= 0) {
if (types[type].includes(encoding)) {
return type;
}
}
Expand Down