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: Upgrade Prettier #1473

Merged
merged 11 commits into from
Nov 1, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
3 changes: 1 addition & 2 deletions _templates/create-package/library/files/package.json.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ to: packages/<%=package%>/package.json
"eslint": "~8.8.0",
"jest": "~27.5.1",
"lint-all": "workspace:~",
"prettier": "~2.5.1",
"prettier": "~3.3.3",
"rimraf": "~3.0.2",
"ts-jest": "~27.1.3",
"typedoc": "~0.24.1",
Expand All @@ -57,7 +57,6 @@ to: packages/<%=package%>/package.json
"jest": true
}
},
"prettier": "@rocket.chat/prettier-config/fuselage",
"jest": {
"preset": "ts-jest",
"errorOnDeprecated": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"husky": "~9.1.6",
"hygen": "~6.2.11",
"pinst": "~3.0.0",
"turbo": "~2.1.3",
"turbo": "~2.2.3",
"update-readme": "workspace:~"
},
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion packages/css-in-js/.prettierrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/css-in-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"eslint": "~8.45.0",
"jest": "~29.7.0",
"lint-all": "workspace:~",
"prettier": "~2.8.7",
"prettier": "~3.3.3",
"rollup": "~2.79.2",
"rollup-plugin-terser": "~7.0.2",
"ts-jest": "~29.2.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/css-in-js/src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getStyleSheet = (): CSSStyleSheet => {
const _styleSheet =
styleTag.sheet ||
Array.from(document.styleSheets).find(
({ ownerNode }) => ownerNode === styleTag
({ ownerNode }) => ownerNode === styleTag,
);

if (!_styleSheet) {
Expand Down Expand Up @@ -60,14 +60,14 @@ const attachRulesIntoStyleSheet: RuleAttacher = (rules) => {
const styleSheet = getStyleSheet();
const index = styleSheet.insertRule(
`@media all{${rules}}`,
styleSheet.cssRules.length
styleSheet.cssRules.length,
);
const insertedRule = styleSheet.cssRules[index];

return () => {
const index = Array.prototype.findIndex.call(
styleSheet.cssRules,
(cssRule: CSSRule): boolean => cssRule === insertedRule
(cssRule: CSSRule): boolean => cssRule === insertedRule,
);
styleSheet.deleteRule(index);
};
Expand Down
36 changes: 18 additions & 18 deletions packages/css-in-js/src/tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,60 @@ describe('tags', () => {
expect(
css`
color: red;
`()
`(),
).toBe('color: red;');
});

it('interpolates numbers and strings', () => {
expect(
css`
border: ${0};
`()
`(),
).toBe('border: 0;');
expect(
css`
color: ${'red'};
`()
`(),
).toBe('color: red;');
});

it('interpolates array', () => {
expect(
css`
border: ${['1', 'px']};
`()
`(),
).toBe('border: 1px;');
});

it('evaluates as a string ignoring undefined, null and false as interpolated values', () => {
expect(
css`
color: ${false} ${undefined} ${null};
`()
`(),
).toBe('color: ;');
});

it('evaluates as a string if some interpolated value is a function', () => {
expect(
css`
color: ${(): string => 'red'};
`()
`(),
).toBe('color: red;');
});

it('interpolates functions with args passed', () => {
expect(
css`
color: ${(colorValue: string): string => colorValue};
`('red')
`('red'),
).toBe('color: red;');
});

it('interpolates other `css` tagged template strings', () => {
expect(
css`
color: ${css`red`};
`()
`(),
).toBe('color: red;');
});

Expand All @@ -83,11 +83,11 @@ describe('tags', () => {
opacity: 1;
}
`};
`()
`(),
).toEqual(
expect.stringMatching(
/^animation-name: rcx-css-([0-9a-z]+);@keyframes rcx-css-\1{/
)
/^animation-name: rcx-css-([0-9a-z]+);@keyframes rcx-css-\1{/,
),
);
});

Expand Down Expand Up @@ -117,7 +117,7 @@ describe('tags', () => {
const escapedAnimationName = keyframes` from { opacity: 0; } `();

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`,
);
});

Expand All @@ -127,7 +127,7 @@ describe('tags', () => {
const escapedAnimationName = keyframes`from { opacity: ${0}; }`();

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`,
);
});

Expand All @@ -138,7 +138,7 @@ describe('tags', () => {
keyframes`from { opacity: ${false} ${undefined} ${null}; }`();

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: ; }}`
`@keyframes ${escapedAnimationName}{from { opacity: ; }}`,
);
});

Expand All @@ -148,19 +148,19 @@ describe('tags', () => {
const escapedAnimationName = keyframes`from { opacity: ${() => 0}; }`();

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`,
);
});

it('interpolates functions with args passed', () => {
const [, freeContext] = holdContext();

const escapedAnimationName = keyframes`from { opacity: ${(
opacityValue: number
opacityValue: number,
) => opacityValue}; }`(0.5);

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: 0.5; }}`
`@keyframes ${escapedAnimationName}{from { opacity: 0.5; }}`,
);
});

Expand All @@ -172,7 +172,7 @@ describe('tags', () => {
`} }`();

expect(freeContext()).toBe(
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`
`@keyframes ${escapedAnimationName}{from { opacity: 0; }}`,
);
});

Expand Down
7 changes: 4 additions & 3 deletions packages/css-in-js/src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ type Evaluable = <T extends readonly unknown[]>(...args: T) => string;
const isEvaluable = (x: unknown): x is Evaluable => typeof x === 'function';

const staticEvaluable = memoize(
<T extends Evaluable>(content: string): T => Object.freeze(() => content) as T
<T extends Evaluable>(content: string): T =>
Object.freeze(() => content) as T,
);

export type cssFn = Evaluable;
Expand All @@ -69,12 +70,12 @@ const evaluateValue = (value: unknown, args: readonly unknown[]): string => {
const reduceEvaluable = (
[first, ...rest]: readonly string[],
values: readonly unknown[],
args: readonly unknown[]
args: readonly unknown[],
): string =>
values
.reduce<string>(
(string, value, i) => string + evaluateValue(value, args) + rest[i],
first
first,
)
.trim();

Expand Down
Loading
Loading