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

Update lg validate and .npmrc #2704

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .changeset/early-maps-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/test': patch
---

Removes `react-test-renderer` dependency
5 changes: 5 additions & 0 deletions .changeset/giant-glasses-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/table': patch
---

Adds missing `@emotion/styled` devDependency
5 changes: 5 additions & 0 deletions .changeset/many-planets-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/toast': patch
---

Removes `react-test-renderer` dependency
5 changes: 5 additions & 0 deletions .changeset/pretty-crews-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/date-picker': patch
---

Adds missing `react-transition-group` dependency
5 changes: 5 additions & 0 deletions .changeset/real-camels-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/validate': major
---

Update `validate` script to read from the local `.npmrc` file in order to determine which packages to exclude from dependency checks
5 changes: 5 additions & 0 deletions .changeset/twelve-planets-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/storybook-addon': patch
---

adds `babel-loader` dependency
7 changes: 2 additions & 5 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
enable-pre-post-scripts=true
public-hoist-pattern[]=@leafygreen-ui/testing-lib
public-hoist-pattern[]=@lg-tools/build
public-hoist-pattern[]=@lg-tools/storybook-addon
public-hoist-pattern[]=@lg-tools/storybook-utils
public-hoist-pattern[]=@storybook/react
public-hoist-pattern[]=@storybook/*
public-hoist-pattern[]=@testing-library/*
public-hoist-pattern[]=@types/*
public-hoist-pattern[]=*jest*
public-hoist-pattern[]=react
public-hoist-pattern[]=react-dom
public-hoist-pattern[]=*jest*
1 change: 1 addition & 0 deletions packages/date-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"date-fns": "^2.30.0",
"lodash": "^4.17.21",
"polished": "^4.2.2",
"react-transition-group": "^4.4.5",
"weekstart": "^2.0.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useRef } from 'react';
import { ChangeEvent, ChangeEventHandler } from 'react';
import { act } from 'react-test-renderer';
import { render } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import { act, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { renderHook } from '@leafygreen-ui/testing-lib';

import { useControlledValue } from './useControlledValue';

const changeEventMock = {
Expand Down
11 changes: 11 additions & 0 deletions packages/icon/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"prebuild": {
"dependsOn": ["^prebuild"],
"inputs": ["src/glyphs/*.svg"],
"outputs": ["src/generated/*.tsx"]
}
}
}
5 changes: 3 additions & 2 deletions packages/table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
"react-intersection-observer": "^8.25.1"
},
"devDependencies": {
"@emotion/styled": "^11.10.5",
"@faker-js/faker": "^8.0.0",
"@leafygreen-ui/code": "workspace:^",
"@leafygreen-ui/button": "workspace:^",
"@leafygreen-ui/badge": "workspace:^",
"@leafygreen-ui/button": "workspace:^",
"@leafygreen-ui/code": "workspace:^",
"@leafygreen-ui/pagination": "workspace:^",
"@leafygreen-ui/tooltip": "workspace:^"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/toast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
},
"devDependencies": {
"@faker-js/faker": "^8.0.0",
"@leafygreen-ui/button": "workspace:^",
"react-test-renderer": "^18.2.0"
"@leafygreen-ui/button": "workspace:^"
},
"homepage": "https://github.com/mongodb/leafygreen-ui/tree/main/packages/toast",
"repository": {
Expand Down
54 changes: 20 additions & 34 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/meta/src/getAllPackages/getAllPackages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAllPackages } from './getAllPackages';

describe('tools/meta/getAllPackages', () => {
beforeAll(() => {
fsx.mkdirSync('./tmp/');
fsx.ensureDirSync('./tmp/');
});
beforeEach(() => {
jest.spyOn(process, 'cwd').mockReturnValue('./tmp');
Expand Down
2 changes: 1 addition & 1 deletion tools/meta/src/getPackageJson/getPackageJson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getPackageJson } from './getPackageJson';

describe('tools/meta/getPackageJson', () => {
beforeAll(() => {
fsx.mkdirSync('./tmp/');
fsx.ensureDirSync('./tmp/');
});
beforeEach(() => {
jest.spyOn(process, 'cwd').mockReturnValue('./tmp');
Expand Down
3 changes: 2 additions & 1 deletion tools/storybook-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
"@storybook/components": "7.6.20",
"@storybook/core-events": "7.6.20",
"@storybook/jest": "^0.2.3",
"@storybook/test": "^7.6.20",
"@storybook/react": "7.6.20",
"@storybook/react-webpack5": "7.6.20",
"@storybook/test": "^7.6.20",
"@storybook/testing-library": "0.2.0",
"@storybook/theming": "7.6.20",
"@svgr/webpack": "8.0.1",
"babel-loader": "9.1.3",
"buffer": "6.0.3",
"file-loader": "6.2.0",
"glob": "10.3.12",
Expand Down
1 change: 0 additions & 1 deletion tools/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"jest-canvas-mock": "2.5.1",
"jest-environment-jsdom": "29.6.2",
"jest-junit": "16.0.0",
"react-test-renderer": "18.2.0",
"regenerator-runtime": "0.14.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions tools/validate/src/dependencies/checkPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import depcheck from 'depcheck';

import { ValidateCommandOptions } from '../validate.types';

import { depcheckOptions, DependencyIssues } from './config';
import { DependencyIssues, getDepcheckOptions } from './config';
import { fixDependencies } from './fixDependencyIssues';
import { logDependencyIssues } from './logDependencyIssues';
import { fixTSconfig, readPackageJson, sortDependenciesByUsage } from './utils';
Expand All @@ -16,7 +16,7 @@ export async function checkPackage(
pkgPath: string,
{ fix, fixTsconfig, verbose }: Partial<ValidateCommandOptions>,
): Promise<boolean> {
const check = await depcheck(pkgPath, depcheckOptions);
const check = await depcheck(pkgPath, getDepcheckOptions());
const pkgName = getPackageName(pkgPath);

if (!pkgName) {
Expand Down
42 changes: 16 additions & 26 deletions tools/validate/src/dependencies/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import depcheck from 'depcheck';
import fsx from 'fs-extra';
import path from 'path';

import { readPackageJson } from './utils';

Expand Down Expand Up @@ -41,36 +43,24 @@ export const ignoreFilePatterns: Array<RegExp> = [
/.*.(input|output).(t|j)sx?/,
];

/**
* @returns an array of hoist patterns from the `.npmrc` file
*/
const getHoistPatterns = () => {
const npmrc = fsx.readFileSync(path.resolve(process.cwd(), '.npmrc'), 'utf8');
const hoistPatterns = npmrc.match(/(?<=public-hoist-pattern\[\]=).*/g);
return hoistPatterns;
};

/**
* These are globally available dev dependencies.
*
* Packages that omit these dependencies will not be flagged for missing dependencies.
*
* Packages that list these dependencies will not be flagged for unused dependencies
*/
export const externalDependencies = [
'@babel/*',
'@emotion/*',
'@leafygreen-ui/mongo-nav',
'@leafygreen-ui/testing-lib',
'@rollup/*',
'@storybook/*',
'@svgr/*',
'@testing-library/*',
'@types/*',
'@typescript-eslint/*',
'buffer',
'eslint*',
'jest',
'jest-*',
'jest-axe',
'prettier*',
'react-*',
'rollup*',
'storybook-*',
'typescript',
'*-loader',
'*-lint*',
export const getHoistedDependencies = () => [
...Array.from(getHoistPatterns() ?? []),
];

/**
Expand All @@ -81,7 +71,7 @@ export const patternsToIgnore = [
'tools/codemods/src/utils/transformations/*/tests',
];

export const depcheckOptions: depcheck.Options = {
ignoreMatches: externalDependencies,
export const getDepcheckOptions = (): depcheck.Options => ({
ignoreMatches: getHoistedDependencies(),
ignorePatterns: patternsToIgnore,
};
});
Loading
Loading