From a7f83c4d6ba9254c06f2bf7b191164d3b1cec800 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 7 Jan 2026 11:45:09 -0700 Subject: [PATCH 1/3] Fix ESLint config The *.tsx files in src/ui were not being properly linted. Now they are, and lint violations have been corrected. Additionally, `vite.config.mjs` was renamed to `vite.config.mts` so that it could be properly linted as well. --- .eslintrc.cjs | 26 +- babel.config.cjs | 6 +- package.json | 3 +- src/ui/App.tsx | 56 +- src/ui/DependencyErrorSection.tsx | 10 + src/ui/ErrorMessage.tsx | 11 +- src/ui/Markdown.tsx | 12 +- src/ui/PackageItem.tsx | 40 +- src/ui/VersionSelector.tsx | 18 +- vite.config.mjs => vite.config.mts | 0 yarn.lock | 1163 +++++++++++++++++++++++++++- 11 files changed, 1297 insertions(+), 48 deletions(-) rename vite.config.mjs => vite.config.mts (100%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index c8b462f5..1488dd58 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -39,15 +39,35 @@ module.exports = { overrides: [ { - files: ['*.ts'], + files: ['*.cjs'], + parserOptions: { + sourceType: 'script', + }, + }, + { + files: ['*.ts', '*.tsx', '*.mts'], extends: ['@metamask/eslint-config-typescript'], }, { - files: ['*.test.ts'], + files: ['*.test.ts', '*.test.tsx'], extends: ['@metamask/eslint-config-jest'], }, + + { + files: ['src/ui/**/*.tsx'], + extends: ['plugin:react/recommended', 'plugin:react/jsx-runtime'], + rules: { + // This rule isn't useful for us + 'react/no-unescaped-entities': 'off', + }, + settings: { + react: { + version: 'detect', + }, + }, + }, ], - ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'dist/'], + ignorePatterns: ['dist/', 'node_modules/'], }; diff --git a/babel.config.cjs b/babel.config.cjs index e0d092a6..35937620 100644 --- a/babel.config.cjs +++ b/babel.config.cjs @@ -4,7 +4,7 @@ module.exports = { env: { test: { presets: ['@babel/preset-env', '@babel/preset-typescript'], - plugins: ['@babel/plugin-transform-modules-commonjs'] - } - } + plugins: ['@babel/plugin-transform-modules-commonjs'], + }, + }, }; diff --git a/package.json b/package.json index f00170b9..3483ea7b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build:ui": "vite build", "build:clean": "rimraf dist && yarn build", "lint": "yarn lint:eslint && yarn lint:misc --check", - "lint:eslint": "eslint . --cache --ext js,ts", + "lint:eslint": "eslint . --cache --ext cjs,cts,js,mjs,mts,ts,tsx", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern", "prepack": "./scripts/prepack.sh", @@ -75,6 +75,7 @@ "eslint-plugin-jsdoc": "^39.6.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-react": "^7.37.5", "jest": "^29.7.0", "jest-it-up": "^3.0.0", "jest-when": "^3.5.2", diff --git a/src/ui/App.tsx b/src/ui/App.tsx index f2b2d2ce..e15ff9e0 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -1,4 +1,3 @@ -import './style.css'; import React, { useState, useEffect, useRef } from 'react'; import { createRoot } from 'react-dom/client'; import { SemVer } from 'semver'; @@ -6,9 +5,16 @@ import { ErrorMessage } from './ErrorMessage.js'; import { PackageItem } from './PackageItem.js'; import { Package, RELEASE_TYPE_OPTIONS, ReleaseType } from './types.js'; +// This file doesn't export anything, it is used to load Tailwind. +// eslint-disable-next-line import/no-unassigned-import +import './style.css'; + // Helper function to compare sets const setsAreEqual = (a: Set, b: Set) => { - if (a.size !== b.size) return false; + if (a.size !== b.size) { + return false; + } + return [...a].every((value) => b.has(value)); }; @@ -21,6 +27,16 @@ type SubmitButtonProps = { onSubmit: () => Promise; }; +/** + * Creates the release branch. + * + * @param props - The props. + * @param props.selections - The packages that have been added to the release. + * @param props.packageDependencyErrors - Errors that are discovered relating to + * dependencies or dependents of packages. + * @param props.onSubmit - The callback to call when the button is pressed. + * @returns The submit button. + */ function SubmitButton({ selections, packageDependencyErrors, @@ -33,7 +49,7 @@ function SubmitButton({ return ( -

{description}

-
    +

    {errorSubject}

    +
    + + Read more + +
    {errorDetails}
    +
    +
      {items.map((dep) => ( -
    • - { +
    • + { + event.preventDefault(); document .getElementById(`package-${dep}`) ?.scrollIntoView({ behavior: 'smooth' }); @@ -56,7 +71,7 @@ export function DependencyErrorSection({ className="cursor-pointer hover:underline" > {dep} - +