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

chore(Format): run it #3008

Closed
wants to merge 1 commit into from
Closed
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
Run format
jrood committed Jan 16, 2025
commit d9df27a45633740ce2154bc3b6bf05ba6e983871
85 changes: 45 additions & 40 deletions packages/eslint-plugin-gamut/src/gamut-import-paths.ts
Original file line number Diff line number Diff line change
@@ -5,49 +5,54 @@ import { createRule } from './createRule';
export default createRule({
create(context) {
return {
'ImportDeclaration[source.value=/(^@)codecademy(\\u002F)gamut/]': function (
node: TSESTree.ImportDeclaration
) {
const filename = context.getFilename();
const importPath = node.source.value;
'ImportDeclaration[source.value=/(^@)codecademy(\\u002F)gamut/]':
function (node: TSESTree.ImportDeclaration) {
const filename = context.getFilename();
const importPath = node.source.value;

const fileDirectory = filename.split('/packages/')[1].split('/')[0];
const importPackage = importPath.split('@codecademy/')[1].split('/')[0];
const fileDirectory = filename.split('/packages/')[1].split('/')[0];
const importPackage = importPath
.split('@codecademy/')[1]
.split('/')[0];

if (fileDirectory === importPackage) {
context.report({
messageId: 'useRelativeImport',
node,
});
return;
}
if (fileDirectory === importPackage) {
context.report({
messageId: 'useRelativeImport',
node,
});
return;
}

if (importPath.includes('/src')) {
const indexOfSrc = node.source.range[0] + importPath.search('/src');
context.report({
...(importPath.endsWith('/src') && {
fix: (fixer) => {
return fixer.removeRange([indexOfSrc + 1, node.range[1] - 2]);
},
}),
messageId: 'removeSrc',
node,
});
return;
}
if (importPath.includes('/dist')) {
const indexOfDist = node.source.range[0] + importPath.search('/dist');
context.report({
...(importPath.endsWith('/dist') && {
fix: (fixer) => {
return fixer.removeRange([indexOfDist + 1, node.range[1] - 2]);
},
}),
messageId: 'removeDist',
node,
});
}
},
if (importPath.includes('/src')) {
const indexOfSrc = node.source.range[0] + importPath.search('/src');
context.report({
...(importPath.endsWith('/src') && {
fix: (fixer) => {
return fixer.removeRange([indexOfSrc + 1, node.range[1] - 2]);
},
}),
messageId: 'removeSrc',
node,
});
return;
}
if (importPath.includes('/dist')) {
const indexOfDist =
node.source.range[0] + importPath.search('/dist');
context.report({
...(importPath.endsWith('/dist') && {
fix: (fixer) => {
return fixer.removeRange([
indexOfDist + 1,
node.range[1] - 2,
]);
},
}),
messageId: 'removeDist',
node,
});
}
},
};
},
defaultOptions: [],
7 changes: 3 additions & 4 deletions packages/gamut-styles/src/ColorMode.tsx
Original file line number Diff line number Diff line change
@@ -71,11 +71,10 @@ interface BackgroundCurrentContextInterface {
'background-current'?: keyof typeof GamutTheme.colors;
}

const BackgroundCurrentContext = createContext<BackgroundCurrentContextInterface>(
{
const BackgroundCurrentContext =
createContext<BackgroundCurrentContextInterface>({
'background-current': undefined,
}
);
});

export function useColorModes(): [
ColorModes,
4 changes: 2 additions & 2 deletions packages/gamut-styles/src/themes/core.ts
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ export const coreTheme = createTheme({
secondary: 'navy-600',
tertiary: 'navy-300',
disabled: 'navy-500',
}
},
},
dark: {
text: {
@@ -126,7 +126,7 @@ export const coreTheme = createTheme({
secondary: 'white-600',
tertiary: 'white-300',
disabled: 'white-500',
}
},
},
})
.addScale('borders', ({ colors }) => ({
2 changes: 1 addition & 1 deletion packages/gamut-styles/src/variance/utils.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const allPropnames = ['mode', 'variant', ...Object.keys(allProps)] as [
*/
const validPropnames = allPropnames.filter(isPropValid);

export type SystemPropNames = typeof allPropnames[number];
export type SystemPropNames = (typeof allPropnames)[number];

export type ElementOrProps = keyof JSX.IntrinsicElements | ThemeProps;
export type ForwardableProps<El extends ElementOrProps, Additional> = Exclude<
2 changes: 1 addition & 1 deletion packages/gamut-styles/utils/functions/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use 'sass:math';
@use "sass:math";

@function strip-units($number) {
@return math.div($number, ($number * 0 + 1));
9 changes: 3 additions & 6 deletions packages/gamut/src/AccordionAreaDeprecated/index.tsx
Original file line number Diff line number Diff line change
@@ -34,12 +34,9 @@ const variants = {
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
*/

export const AccordionAreaDeprecated: React.FC<AccordionAreaDeprecatedProps> = ({
children,
className,
expanded,
top,
}) => {
export const AccordionAreaDeprecated: React.FC<
AccordionAreaDeprecatedProps
> = ({ children, className, expanded, top }) => {
const [delayExpanded, setDelayExpanded] = useState(expanded);

useIsomorphicLayoutEffect(() => {
4 changes: 3 additions & 1 deletion packages/gamut/src/AccordionButtonDeprecated/index.tsx
Original file line number Diff line number Diff line change
@@ -59,7 +59,9 @@ const buttonThemes = {
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
*/

export const AccordionButtonDeprecated: React.FC<AccordionButtonDeprecatedProps> = ({
export const AccordionButtonDeprecated: React.FC<
AccordionButtonDeprecatedProps
> = ({
children,
className,
expanded,
10 changes: 4 additions & 6 deletions packages/gamut/src/Alert/elements.tsx
Original file line number Diff line number Diff line change
@@ -7,9 +7,8 @@ import { Box } from '../Box';
import { AlertProps } from './Alert';
import { placementVariants } from './variants';

const StyledAlertBanner = styled(Background)<
Pick<AlertProps, 'type' | 'placement'>
>(placementVariants);
const StyledAlertBanner =
styled(Background)<Pick<AlertProps, 'type' | 'placement'>>(placementVariants);

export const AlertBanner = forwardRef<
HTMLDivElement,
@@ -34,9 +33,8 @@ export const AlertBanner = forwardRef<
)
);

const StyledAlertBox = styled(Box)<Pick<AlertProps, 'type' | 'placement'>>(
placementVariants
);
const StyledAlertBox =
styled(Box)<Pick<AlertProps, 'type' | 'placement'>>(placementVariants);

export const AlertBox = forwardRef<
HTMLDivElement,
2 changes: 1 addition & 1 deletion packages/gamut/src/Button/shared/types.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { buttonProps, buttonVariants } from './styles';

export interface ButtonBaseProps extends StyleProps<typeof buttonProps> {
onClick?: HTMLProps<HTMLButtonElement>['onClick'];
variant?: typeof buttonVariants[number];
variant?: (typeof buttonVariants)[number];
size?: 'normal' | 'small' | 'large';
as?: never;
mode?: ColorModes;
Original file line number Diff line number Diff line change
@@ -3,12 +3,9 @@ import * as React from 'react';
import { ConnectedRadio, ConnectedRadioGroup } from '.';
import { ConnectedRadioGroupInputProps } from './types';

export const ConnectedRadioGroupInput: React.FC<ConnectedRadioGroupInputProps> = ({
name,
options,
disabled,
...rest
}) => {
export const ConnectedRadioGroupInput: React.FC<
ConnectedRadioGroupInputProps
> = ({ name, options, disabled, ...rest }) => {
return (
<ConnectedRadioGroup name={name} {...rest}>
{options.map((elem) => {
10 changes: 2 additions & 8 deletions packages/gamut/src/DataList/Rows/HeaderRow.tsx
Original file line number Diff line number Diff line change
@@ -27,14 +27,8 @@ export const Header: HeaderComponent = ({
empty = false,
hideSelectAll,
}) => {
const {
expandable,
selectable,
onSelect,
onFilter,
onSort,
prefixId,
} = useControlContext();
const { expandable, selectable, onSelect, onFilter, onSort, prefixId } =
useControlContext();
Comment on lines +30 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these fixes seems a little off to me (including this one). i'll take a look at what changed + chat with the broader web plat team, def something we just inadvertently changed during the gamut migration


return (
<ListHeader>
9 changes: 2 additions & 7 deletions packages/gamut/src/Disclosure/helpers.tsx
Original file line number Diff line number Diff line change
@@ -46,13 +46,8 @@ export const renderButton = (buttonProps: {
ctaText: string;
href?: string | undefined;
}) => {
const {
buttonPlacement,
buttonType,
ctaCallback,
ctaText,
href,
} = buttonProps;
const { buttonPlacement, buttonType, ctaCallback, ctaText, href } =
buttonProps;
const sharedProps = {
mt: 8 as const,
lineHeight: 'normal',
1 change: 0 additions & 1 deletion packages/gamut/src/Form/__tests__/FormGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ describe('FormGroup', () => {

view.getByLabelText(optionalLabelText);
});

});
describe('when htmlFor is not provided', () => {
it('renders Label as a div', () => {
11 changes: 6 additions & 5 deletions packages/gamut/src/Form/elements/FormGroupLabel.tsx
Original file line number Diff line number Diff line change
@@ -73,13 +73,14 @@ export const FormGroupLabel: React.FC<FormGroupLabelProps> = ({
as={htmlFor ? 'label' : 'div'}
>
{children}
{!isSoloField && (
required ? (
<Text as="span" aria-hidden>*</Text>
{!isSoloField &&
(required ? (
<Text as="span" aria-hidden>
*
</Text>
) : (
'\u00A0(optional)'
)
)}
))}
</Label>
{infotip && <InfoTip {...infotip} />}
</FlexBox>
10 changes: 4 additions & 6 deletions packages/gamut/src/Form/inputs/Input.tsx
Original file line number Diff line number Diff line change
@@ -58,9 +58,8 @@ export interface InputWrapperProps extends InputProps {
/** We greatly prefer NOT to do this but ReactRecurly has some specific needs around focus-styles + padding that force us to export them seperately. If we ever stop using React-Recurly, this code will be 🔪.
*tldr: Do not do this unless you have already talked to Web-Plat and have failed to find any alternate (and better) solutions. */

export const reactRecurlyFormFieldFocusStyles = system.css(
formFieldFocusStyles
);
export const reactRecurlyFormFieldFocusStyles =
system.css(formFieldFocusStyles);

export const reactRecurlyFormFieldPaddingStyles = system.css(
formFieldPaddingStyles
@@ -116,9 +115,8 @@ export const Input = forwardRef<HTMLInputElement, InputWrapperProps>(
) => {
const [activatedStyle, setActivatedStyle] = useState(false);

const { color, icon } = inputStates[
getInputState(Boolean(error), Boolean(valid))
];
const { color, icon } =
inputStates[getInputState(Boolean(error), Boolean(valid))];

/*
* @remarks We would love to properly type this with generics, but, alas, we cannot yet. See comments on lines 45-47 for more detail.
Original file line number Diff line number Diff line change
@@ -11,15 +11,9 @@ export interface GridFormRadioGroupInputProps extends BaseFormInputProps {
setValue: (name: string, value: string) => void;
}

export const GridFormRadioGroupInput: React.FC<GridFormRadioGroupInputProps> = ({
className,
disabled,
field,
register,
setValue,
required,
error,
}) => {
export const GridFormRadioGroupInput: React.FC<
GridFormRadioGroupInputProps
> = ({ className, disabled, field, register, setValue, required, error }) => {
const ariaLabel: string | undefined =
field.ariaLabel ?? (isString(field.label) ? field.label : undefined);

Original file line number Diff line number Diff line change
@@ -11,11 +11,9 @@ export type GridFormSweetContainerInputProps = {
label: string;
};

export const GridFormSweetContainerInput: React.FC<GridFormSweetContainerInputProps> = ({
register,
field: { name },
label,
}) => {
export const GridFormSweetContainerInput: React.FC<
GridFormSweetContainerInputProps
> = ({ register, field: { name }, label }) => {
return (
<Box
height="1px"
Original file line number Diff line number Diff line change
@@ -85,11 +85,9 @@ type GridFormInputGroupTestComponentProps = GridFormInputGroupProps & {
mode?: 'onSubmit' | 'onChange';
};

export const GridFormInputGroupTestComponent: React.FC<GridFormInputGroupTestComponentProps> = ({
field,
mode = 'onSubmit',
...rest
}) => {
export const GridFormInputGroupTestComponent: React.FC<
GridFormInputGroupTestComponentProps
> = ({ field, mode = 'onSubmit', ...rest }) => {
return (
<FormContext mode={mode}>
<GridFormInputGroup field={field} {...rest} />
Original file line number Diff line number Diff line change
@@ -12,21 +12,19 @@ type GridFormSectionTestComponentProps = GridFormSectionProps & {
mode?: 'onSubmit' | 'onChange';
};

export const GridFormContentTestComponent: React.FC<GridFormContentTestComponentProps> = ({
field,
mode = 'onSubmit',
}) => {
export const GridFormContentTestComponent: React.FC<
GridFormContentTestComponentProps
> = ({ field, mode = 'onSubmit' }) => {
return (
<FormContext mode={mode}>
<GridFormContent field={field} key={field.name} />
</FormContext>
);
};

export const GridFormSectionTestComponent: React.FC<GridFormSectionTestComponentProps> = ({
fields,
mode = 'onSubmit',
}) => {
export const GridFormSectionTestComponent: React.FC<
GridFormSectionTestComponentProps
> = ({ fields, mode = 'onSubmit' }) => {
return (
<FormContext mode={mode}>
<GridFormSection fields={fields} />
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ describe('GridFormSections', () => {
value: 'Do you know what that is?',
},
});
})
});

await view.findByText('what is it?');
await view.findByText('not enough updog');
2 changes: 1 addition & 1 deletion packages/gamut/src/List/elements.tsx
Original file line number Diff line number Diff line change
@@ -351,7 +351,7 @@ export interface ColProps
StyleProps<typeof columnType>,
StyleProps<typeof columnStates>,
StyleProps<typeof columnJustify>,
StyleProps<typeof system['layout']> {}
StyleProps<(typeof system)['layout']> {}

export const ColEl = styled(
'div',
Loading