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(deps): bump prettier and @types/prettier #4384

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"printWidth": 100,
"singleQuote": true,
"tabWidth": 4
"tabWidth": 4,
"trailingComma": "es5"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/babel__core": "^7.20.5",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.10",
"@types/prettier": "^2.7.3",
"@types/prettier": "^3.0.0",
"bytes": "^3.1.2",
"es-module-lexer": "^1.5.4",
"eslint": "^9.7.0",
Expand All @@ -65,7 +65,7 @@
"lint-staged": "^15.2.7",
"magic-string": "^0.30.10",
"nx": "19.4.3",
"prettier": "^2.8.8",
"prettier": "^3.3.3",
"rollup": "^4.18.1",
"terser": "^5.31.2",
"ts-jest": "^29.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,33 @@ function computePublicPropsConfig(
publicPropertyMetas: DecoratorMeta[],
classBodyItems: NodePath<ClassBodyItem>[]
) {
return publicPropertyMetas.reduce((acc, { propertyName, decoratedNodeType }) => {
if (!(propertyName in acc)) {
acc[propertyName] = {};
}
acc[propertyName].config |= getPropertyBitmask(decoratedNodeType);
return publicPropertyMetas.reduce(
(acc, { propertyName, decoratedNodeType }) => {
if (!(propertyName in acc)) {
acc[propertyName] = {};
}
acc[propertyName].config |= getPropertyBitmask(decoratedNodeType);

if (
decoratedNodeType === DECORATOR_TYPES.GETTER ||
decoratedNodeType === DECORATOR_TYPES.SETTER
) {
// With the latest decorator spec, only one of the getter/setter pair needs a decorator.
// We need to add the proper bitmask for the sibling getter/setter if it exists.
const pairType = getSiblingGetSetPairType(
propertyName,
decoratedNodeType,
classBodyItems
);
if (pairType) {
acc[propertyName].config |= getPropertyBitmask(pairType);
if (
decoratedNodeType === DECORATOR_TYPES.GETTER ||
decoratedNodeType === DECORATOR_TYPES.SETTER
) {
// With the latest decorator spec, only one of the getter/setter pair needs a decorator.
// We need to add the proper bitmask for the sibling getter/setter if it exists.
const pairType = getSiblingGetSetPairType(
propertyName,
decoratedNodeType,
classBodyItems
);
if (pairType) {
acc[propertyName].config |= getPropertyBitmask(pairType);
}
}
}

return acc;
}, {} as { [key: string]: { [key: string]: number } });
return acc;
},
{} as { [key: string]: { [key: string]: number } }
);
}

export default function transform(
Expand Down
29 changes: 16 additions & 13 deletions packages/@lwc/babel-plugin-component/src/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ function validateImportedLwcDecoratorUsage(
) {
engineImportSpecifiers
.filter(({ name }) => isLwcDecoratorName(name))
.reduce((acc, { name, path }) => {
// Get a list of all the local references
const local = path.get('imported') as NodePath<types.Identifier>;
const references = getReferences(local).map((reference) => ({
name,
reference,
}));

return [...acc, ...references] as {
name: string;
reference: NodePath<types.Node>;
}[];
}, [] as { name: string; reference: NodePath<types.Node> }[])
.reduce(
(acc, { name, path }) => {
// Get a list of all the local references
const local = path.get('imported') as NodePath<types.Identifier>;
const references = getReferences(local).map((reference) => ({
name,
reference,
}));

return [...acc, ...references] as {
name: string;
reference: NodePath<types.Node>;
}[];
},
[] as { name: string; reference: NodePath<types.Node> }[]
)
.forEach(({ name, reference }) => {
// Get the decorator from the identifier
// If the the decorator is:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[]) {
const objectProperties = [];
const trackDecoratorMetas = decoratorMetas.filter(isTrackDecorator);
if (trackDecoratorMetas.length) {
const config = trackDecoratorMetas.reduce((acc, meta) => {
acc[meta.propertyName] = TRACK_PROPERTY_VALUE;
return acc;
}, {} as { [key: string]: number });
const config = trackDecoratorMetas.reduce(
(acc, meta) => {
acc[meta.propertyName] = TRACK_PROPERTY_VALUE;
return acc;
},
{} as { [key: string]: number }
);
objectProperties.push(
t.objectProperty(t.identifier(LWC_COMPONENT_PROPERTIES.TRACK), t.valueToNode(config))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[]
const wiredValues = decoratorMetas.filter(isWireDecorator).map(({ path }) => {
const [id, config] = path.get('expression.arguments') as [
NodePath,
NodePath<types.ObjectExpression> | undefined
NodePath<types.ObjectExpression> | undefined,
];

const propertyName = (path.parentPath.get('key.name') as any).node as string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ if (process.env.IS_BROWSER) {
// aria* properties
for (const [propName, descriptor] of entries(ariaReflectionPolyfillDescriptors) as [
name: string,
descriptor: PropertyDescriptor
descriptor: PropertyDescriptor,
][]) {
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, descriptor);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/@lwc/engine-core/src/framework/wiring/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ContextValue = Record<string, any>;

export interface WireAdapter<
Config extends ConfigValue = ConfigValue,
Context extends ContextValue = ContextValue
Context extends ContextValue = ContextValue,
> {
update(config: Config, context?: Context): void;
connect(): void;
Expand All @@ -25,12 +25,12 @@ export interface WireAdapter<
export interface WireAdapterConstructor<
Config extends ConfigValue = ConfigValue,
Value = any,
Context extends ContextValue = ContextValue
Context extends ContextValue = ContextValue,
> {
new (callback: DataCallback<Value>, sourceContext?: { tagName: string }): WireAdapter<
Config,
Context
>;
new (
callback: DataCallback<Value>,
sourceContext?: { tagName: string }
): WireAdapter<Config, Context>;
configSchema?: Record<keyof Config, WireAdapterSchemaValue>;
contextSchema?: Record<keyof Context, WireAdapterSchemaValue>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ function createHCONFIG2JSPreprocessor(config, logger, emitter) {
const describeTitle = path.relative(basePath, suiteDir).split(path.sep).join(' ');

try {
const { code: testCode, watchFiles: testWatchFiles } = await getTestModuleCode(
filePath
);
const { code: componentDef, watchFiles: componentWatchFiles } = await getCompiledModule(
suiteDir
);
const { code: testCode, watchFiles: testWatchFiles } =
await getTestModuleCode(filePath);
const { code: componentDef, watchFiles: componentWatchFiles } =
await getCompiledModule(suiteDir);
// You can add an `.only` file alongside an `index.spec.js` file to make it `fdescribe()`
const onlyFileExists = await exists(path.join(suiteDir, '.only'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ describe('slot forwarding', () => {
const defaultSlotTextIndex = USE_LIGHT_DOM_SLOT_FORWARDING
? 12
: USE_COMMENTS_FOR_FRAGMENT_BOOKENDS
? 11
: 4;
? 11
: 4;
const defaultSlotCommentIndex = USE_LIGHT_DOM_SLOT_FORWARDING
? 13
: USE_COMMENTS_FOR_FRAGMENT_BOOKENDS
? 12
: 5;
? 12
: 5;

expect(lightLightLeaf.childNodes[defaultSlotTextIndex].textContent).toEqual(
expectedDefaultSlot.textContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,20 @@ describe('regression test (#3827)', () => {
process.env.NATIVE_SHADOW
? []
: !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE
? [
`leaf:${currentLeafName}:connectedCallback`,
`leaf:${previousLeafName}:disconnectedCallback`,
]
: [`leaf:${currentLeafName}:connectedCallback`],
? [
`leaf:${currentLeafName}:connectedCallback`,
`leaf:${previousLeafName}:disconnectedCallback`,
]
: [`leaf:${currentLeafName}:connectedCallback`],
elseIfBlock: (currentLeafName, previousLeafName) =>
process.env.NATIVE_SHADOW
? []
: !lwcRuntimeFlags.DISABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE
? [
`leaf:${currentLeafName}:connectedCallback`,
`leaf:${previousLeafName}:disconnectedCallback`,
]
: [`leaf:${currentLeafName}:connectedCallback`],
? [
`leaf:${currentLeafName}:connectedCallback`,
`leaf:${previousLeafName}:disconnectedCallback`,
]
: [`leaf:${currentLeafName}:connectedCallback`],
},
{
fixtureName: 'light DOM',
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Here `<functional-area>` would be the broader area under test such as events, sl

In the above example, `app` and `child` are present because the test verifies event handling between a child and parent component and to reflect the playground setup, but are not required for every test. `<specific-repro>.html` may also use the `<test-case>` template currently used in some lwc-integration tests to cleanly display Github issue and Lightning Web Components playground links.

The level describe blocks inside `<specific-repro>.spec.js` should also note the Github issue number if relevant. For example, `` describe('Issue 657: Cannot attach event in `connectedCallback`', () => {...}) ``.
The level describe blocks inside `<specific-repro>.spec.js` should also note the Github issue number if relevant. For example, ``describe('Issue 657: Cannot attach event in `connectedCallback`', () => {...})``.

If it doesn't require additional components for the repro, you could simply have

Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/ssr-compiler/src/compile-template/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const bYieldEscapedString = esTemplateWithYield<
EsIdentifier,
EsIdentifier,
EsIdentifier,
EsIdentifier
EsIdentifier,
]
>`
const ${is.identifier} = ${is.expression};
Expand Down
4 changes: 2 additions & 2 deletions packages/@lwc/ssr-compiler/src/estemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function esTemplateImpl<RetType = EsNode, ArgTypes extends ReplacementNode[] = R

export function esTemplate<
RetType = EsNode,
ArgTypes extends ReplacementNode[] = ReplacementNode[]
ArgTypes extends ReplacementNode[] = ReplacementNode[],
>(
javascriptSegments: TemplateStringsArray,
...validatorFns: Validator[]
Expand All @@ -149,7 +149,7 @@ export function esTemplate<

export function esTemplateWithYield<
RetType = EsNode,
ArgTypes extends ReplacementNode[] = ReplacementNode[]
ArgTypes extends ReplacementNode[] = ReplacementNode[],
>(
javascriptSegments: TemplateStringsArray,
...validatorFns: Validator[]
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/ssr-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class LightningElement {

getAttribute(attrName: string): string | null {
const value = this.__attrs?.[attrName];
return value === true ? '' : value ?? null;
return value === true ? '' : (value ?? null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ if (process.env.NODE_ENV !== 'test') {
this,
ArraySlice.call(arguments as unknown as unknown[]) as [
namespace: string,
localName: string
localName: string,
]
)
);
Expand Down
4 changes: 2 additions & 2 deletions packages/@lwc/synthetic-shadow/src/faux-shadow/slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defineProperties(HTMLSlotElement.prototype, {
return originalAssignedElements.apply(
this,
ArraySlice.call(arguments as unknown as unknown[]) as [
options?: AssignedNodesOptions
options?: AssignedNodesOptions,
]
);
}
Expand All @@ -176,7 +176,7 @@ defineProperties(HTMLSlotElement.prototype, {
return originalAssignedNodes.apply(
this,
ArraySlice.call(arguments as unknown as unknown[]) as [
options?: AssignedNodesOptions
options?: AssignedNodesOptions,
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/template-compiler/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function getTemplateRoot(
ctx.throw(
ParserDiagnostics.MULTIPLE_ROOTS_FOUND,
[],
duplicateRoot ? ast.sourceLocation(duplicateRoot) : duplicateRoot ?? undefined
duplicateRoot ? ast.sourceLocation(duplicateRoot) : (duplicateRoot ?? undefined)
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/template-compiler/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface EventListener extends BaseNode {
}

export interface Directive<
T extends keyof typeof ElementDirectiveName | keyof typeof RootDirectiveName
T extends keyof typeof ElementDirectiveName | keyof typeof RootDirectiveName,
> extends BaseNode {
type: 'Directive';
name: T;
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/generate-license-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function main() {
'\n'
)}`.trim() + '\n';

const formattedLicense = prettier.format(newLicense, {
const formattedLicense = await prettier.format(newLicense, {
parser: 'markdown',
});

Expand Down
20 changes: 11 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1912,10 +1912,12 @@
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109"
integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==

"@types/prettier@^2.7.3":
version "2.7.3"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f"
integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==
"@types/prettier@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-3.0.0.tgz#e9bc8160230d3a461dab5c5b41cceef1ef723057"
integrity sha512-mFMBfMOz8QxhYVbuINtswBp9VL2b4Y0QqYHwqLz3YbgtfAcat2Dl6Y1o4e22S/OVE6Ebl9m7wWiMT2lSbAs1wA==
dependencies:
prettier "*"

"@types/[email protected]":
version "1.20.2"
Expand Down Expand Up @@ -9285,16 +9287,16 @@ prepend-http@^2.0.0:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==

prettier@*, prettier@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==

[email protected]:
version "2.8.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.1.tgz#4e1fd11c34e2421bc1da9aea9bd8127cd0a35efc"
integrity sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==

prettier@^2.8.8:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

pretty-format@^29.0.0, pretty-format@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
Expand Down
Loading