Skip to content

Commit 1b26fe5

Browse files
chore: linting fixes (#261)
## **Description** This pull request implements several important TypeScript and linting improvements to enhance code quality and developer experience. Key changes include: - Added `.tsx` extension to ESLint configuration to ensure proper linting of React TypeScript components - Configured TypeScript path alias for `@metamask/design-system-react` to enable direct imports and proper IDE support - Enforced `import type` syntax through ESLint to prevent runtime errors in `.mjs` files - Updated TypeScript configuration to include the `stories` folder and its files for design-tokens - Ran `prettier` to apply consistent formatting across all affected files These changes collectively improve code maintainability, type safety, and development workflow efficiency. ## **Related issues** Fixes: N/A ## **Manual testing steps** 1. Run `yarn lint` and ensure there are no TypeScript linting errors 2. Run `yarn prettier .` to verify that all files adhere to the formatting rules ## **Pre-merge author checklist** - [x] Followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) - [x] Completed this PR template - [x] Verified the linting and formatting updates - [x] Applied appropriate labels as per [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md) ## **Pre-merge reviewer checklist** - [ ] Manually tested the PR to confirm no regressions - [ ] Verified all linting and formatting changes - [ ] Confirmed that the updates improve code maintainability
1 parent 05f9df9 commit 1b26fe5

29 files changed

+191
-179
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/unambiguous */
12
module.exports = {
23
root: true,
34
extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"create-component:react": "yarn workspace @metamask/design-system-react create-component",
2222
"create-package": "ts-node scripts/create-package",
2323
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies",
24+
"lint:clear-cache": "rimraf .eslintcache",
2425
"lint:dependencies": "depcheck && yarn dedupe --check",
2526
"lint:dependencies:fix": "depcheck && yarn dedupe",
26-
"lint:eslint": "eslint . --cache --ext js,cjs,mjs,ts",
27-
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
27+
"lint:eslint": "eslint . --cache --ext js,cjs,mjs,ts,tsx",
28+
"lint:fix": "yarn lint:clear-cache && yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
2829
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .prettierignore",
2930
"prepack": "./scripts/prepack.sh",
3031
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
extends: ['../../.eslintrc.js'],
3+
env: {
4+
browser: true,
5+
node: false,
6+
},
7+
rules: {
8+
'no-restricted-globals': 'off',
9+
},
10+
overrides: [
11+
{
12+
files: ['**/*.{ts,tsx}'],
13+
parserOptions: {
14+
tsconfigRootDir: __dirname,
15+
project: ['./tsconfig.json'],
16+
},
17+
},
18+
],
19+
};

packages/design-system-react/scripts/create-component/ComponentName/ComponentName.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
21
import type { Meta, StoryObj } from '@storybook/react';
2+
33
import { ComponentName } from './ComponentName';
44
import README from './README.mdx';
55

packages/design-system-react/scripts/create-component/ComponentName/ComponentName.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react';
21
import { render, screen } from '@testing-library/react';
2+
import React from 'react';
3+
34
import { ComponentName } from './ComponentName';
4-
import '@testing-library/jest-dom';
55

66
describe('ComponentName Component', () => {
77
it('renders children correctly', () => {

packages/design-system-react/scripts/create-component/ComponentName/ComponentName.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2+
23
import { twMerge } from '../../utils/tw-merge';
3-
import { ComponentNameProps } from './ComponentName.types';
4+
import type { ComponentNameProps } from './ComponentName.types';
45

56
export const ComponentName: React.FC<ComponentNameProps> = ({
67
children,

packages/design-system-react/src/components/button/Button.stories.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/design-system-react/src/components/button/Button.test.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/design-system-react/src/components/button/Button.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/design-system-react/src/components/button/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)