Skip to content

Commit

Permalink
Fix linter and TypeScript warnings (mdn#23693)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Jul 8, 2024
1 parent 4803bed commit c37716d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lint/linter/test-schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This file is a part of @mdn/browser-compat-data
* See LICENSE file for more information. */

import Ajv from 'ajv';
import { Ajv } from 'ajv';
import ajvErrors from 'ajv-errors';
import ajvFormats from 'ajv-formats';
import betterAjvErrors from 'better-ajv-errors';
Expand Down
4 changes: 2 additions & 2 deletions lint/linter/test-spec-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const specsExceptions = [
];

const allowedSpecURLs = [
...specData
...(specData
.filter((spec) => spec.standing == 'good')
.map((spec) => [
spec.url,
Expand All @@ -48,7 +48,7 @@ const allowedSpecURLs = [
spec.series.nightlyUrl,
])
.flat()
.filter((url) => !!url),
.filter((url) => !!url) as string[]),
...specsExceptions,
];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"diff": "node --loader=ts-node/esm --no-warnings=ExperimentalWarning scripts/diff.ts",
"unittest": "NODE_ENV=test c8 mocha index.test.ts --recursive \"{,!(node_modules)/**}/*.test.ts\"",
"coverage": "c8 report -r lcov && open-cli coverage/lcov-report/index.html",
"format": "eslint . && prettier --check .",
"format": "eslint . && prettier --check . && tsc --noEmit",
"format:fix": "eslint --quiet --fix . && prettier --write .",
"lint": "node --loader=ts-node/esm --no-warnings=ExperimentalWarning lint/lint.ts",
"lint:fix": "node --loader=ts-node/esm --no-warnings=ExperimentalWarning lint/fix.ts",
Expand Down
4 changes: 3 additions & 1 deletion scripts/bulk-editor/tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import removeCommand from './remove.js';
const command = {
command: 'tags',
description: 'Modify tags',
// eslint-disable-next-line @typescript-eslint/no-empty-function
// Yargs requires a handler method present, regardless if it does anything
// eslint-disable-next-line @typescript-eslint/no-empty-function,jsdoc/require-jsdoc
handler: () => {},
// eslint-disable-next-line jsdoc/require-jsdoc
builder: (yargs) =>
yargs.command([addCommand, removeCommand]).demandCommand().help(),
};
Expand Down
10 changes: 4 additions & 6 deletions scripts/bulk-editor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ const dirname = fileURLToPath(new URL('.', import.meta.url));

/**
* Updates the specified key in the given JSON object using the provided updater function.
*
* @param key The key to update in dot notation (e.g., 'api.foobar').
* @param json The JSON object to update.
* @param updater The function to apply to the '__compat' property of the value corresponding to the key.
* @returns The updated JSON object.
*/
const performUpdate = (key, json, updater) => {
const performUpdate = (key: string, json: any, updater: (any) => any): any => {
const parts = key.split('.');
if (!(parts[0] in json)) {
console.warn('Key not found in file!');
Expand All @@ -42,11 +41,10 @@ const performUpdate = (key, json, updater) => {

/**
* Updates features in multiple JSON files based on the provided feature IDs and updater function.
*
* @param {string[]} featureIDs An array of feature IDs to update.
* @param {Function} updater The updater function to apply to each matching feature.
* @param featureIDs An array of feature IDs to update.
* @param updater The updater function to apply to each matching feature.
*/
export const updateFeatures = (featureIDs, updater) => {
export const updateFeatures = (featureIDs: string[], updater: (any) => any) => {
for (const dir of dataFolders) {
const paths = new fdir()
.withBasePath()
Expand Down
14 changes: 11 additions & 3 deletions scripts/update-browser-releases/safari.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ import stringify from '../lib/stringify-and-order-properties.js';

import { newBrowserEntry, updateBrowserEntry } from './utils.js';

interface Release {
version: string;
engineVersion: string;
channel: 'current' | 'beta' | 'retired';
date: string;
releaseNote: string;
}

/**
* extractReleaseData - Extract release info from string given by Apple
* @param str The string with release information
* E.g., Released September 18, 2023 — Version 17 (19616.1.27)
* @returns Data for the release
*/
const extractReleaseData = (str) => {
const extractReleaseData = (str): Release | null => {
// Note: \s is needed as some spaces in Apple source are non-breaking
const result =
/Released\s+(.*)\s*\s*(?:Version\s+)?(\d+(?:\.\d+)*)\s*(\s*beta)?\s*\((.*)\)/.exec(
Expand Down Expand Up @@ -65,7 +73,7 @@ export const updateSafariReleases = async (options) => {
//
// Collect release data from JSON
//
const releaseData = [];
const releaseData: Release[] = [];
for (const id in releases) {
// Filter out data from "Technologies" overview page
if (releases[id].kind !== 'article') {
Expand Down Expand Up @@ -97,7 +105,7 @@ export const updateSafariReleases = async (options) => {
//
// Find current release
//
const dates = [];
const dates: string[] = [];
releaseData.forEach((release) => {
if (release.channel !== 'beta') {
dates.push(release.date);
Expand Down

0 comments on commit c37716d

Please sign in to comment.