Skip to content

Commit

Permalink
[EngSys] upgrade to prettier v3
Browse files Browse the repository at this point in the history
***NO_CI***

- remove dev dependency `prettier` from non-tool packages when possible and
  update them to run vendored prettier for `check-format` and `format` scripts

- upgrade rest of packages to prettier v3

- run `rush format` for all rush packages

This is a follow-up to #28127 to
move the rest of repo to prettier v3.
  • Loading branch information
jeremymeng authored and benbp committed Jan 10, 2024
1 parent 7faf4ac commit 12b4dcc
Show file tree
Hide file tree
Showing 2,828 changed files with 20,030 additions and 20,055 deletions.
754 changes: 377 additions & 377 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/tools/eslint-plugin-azure-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"chai": "^4.2.0",
"eslint": "^8.50.0",
"mocha": "^10.0.0",
"prettier": "^2.5.1",
"prettier": "^3.1.0",
"rimraf": "^3.0.0",
"source-map-support": "^0.5.9",
"typescript": "~5.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export = {
preprocess: (text: string): string[] => [text],
postprocess: (messages: Linter.LintMessage[][]): Linter.LintMessage[] =>
messages[0].filter(
(message: Linter.LintMessage): boolean => message.ruleId !== "no-unused-expressions"
(message: Linter.LintMessage): boolean => message.ruleId !== "no-unused-expressions",
),
supportsAutofix: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export = {
meta: getRuleMetaData(
"github-source-headers",
"require copyright headers in every source file",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
/\.ts$/.test(context.filename)
Expand All @@ -48,7 +48,7 @@ export = {
fix(fixer: Rule.RuleFixer): Rule.Fix {
return fixer.insertTextBefore(
(headerComments[0] as any) || node,
expectedComments
expectedComments,
);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { stripFileName } from "../utils/verifiers";
export = {
meta: getRuleMetaData(
"ts-apiextractor-json-types",
"force api-extractor.json to configure types in a consistent way"
"force api-extractor.json to configure types in a consistent way",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const bannedPrefixes = [
export = {
meta: getRuleMetaData(
"ts-apisurface-standardized-verbs",
"require client methods to use standardized verb prefixes and suffixes where possible"
"require client methods to use standardized verb prefixes and suffixes where possible",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
({
Expand All @@ -47,7 +47,7 @@ export = {

// look for if any of the banned prefixes are used
const usedPrefix = bannedPrefixes.find((bannedPrefix: string): boolean =>
methodName.startsWith(bannedPrefix)
methodName.startsWith(bannedPrefix),
);
if (usedPrefix !== undefined) {
context.report({
Expand All @@ -57,5 +57,5 @@ export = {
}
});
},
} as Rule.RuleListener),
}) as Rule.RuleListener,
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getDefinedType = (type: any): Type => {
return type;
}
const nonUndefinedType = type.types.find(
(candidate: Type): boolean => candidate.getFlags() !== TypeFlags.Undefined
(candidate: Type): boolean => candidate.getFlags() !== TypeFlags.Undefined,
);
return nonUndefinedType !== undefined ? nonUndefinedType : type;
};
Expand Down Expand Up @@ -72,7 +72,7 @@ const isValidSymbol = (symbol: TSSymbol, typeChecker: TypeChecker): boolean => {
const isValidParam = (
param: TSESTree.Parameter,
typeChecker: TypeChecker,
converter: ParserWeakMapESTreeToTSNode
converter: ParserWeakMapESTreeToTSNode,
): boolean => {
if (param.type !== "Identifier" || param.typeAnnotation === undefined) {
return false;
Expand Down Expand Up @@ -101,7 +101,7 @@ const isValidParam = (
export = {
meta: getRuleMetaData(
"ts-apisurface-supportcancellation",
"require async client methods to accept an AbortSignalLike parameter"
"require async client methods to accept an AbortSignalLike parameter",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const parserServices = context.sourceCode.parserServices as ParserServices;
Expand All @@ -126,7 +126,7 @@ export = {
if (
TSFunction.async &&
TSFunction.params.every(
(param: TSESTree.Parameter): boolean => !isValidParam(param, typeChecker, converter)
(param: TSESTree.Parameter): boolean => !isValidParam(param, typeChecker, converter),
)
) {
context.report({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export = {
meta: getRuleMetaData(
"ts-config-include",
"force tsconfig.json's 'include' value to at least contain 'src/**/*.ts', 'test/**/*.ts', and 'samples-dev/**/*.ts'",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand All @@ -33,7 +33,7 @@ export = {

// check the node corresponding to include to see if its value contains "src/**/*.ts", "test/**/*.ts", and "samples-dev/**/*.ts"
"ExpressionStatement > ObjectExpression > Property[key.value='include']": (
node: Property
node: Property,
): void => {
// check if the value is an array of literals
if (node.value.type !== "ArrayExpression") {
Expand All @@ -46,7 +46,7 @@ export = {
const nodeValue = node.value as ArrayExpression;

const nonLiteral = nodeValue.elements.find(
(element: any): boolean => element.type !== "Literal"
(element: any): boolean => element.type !== "Literal",
);

if (nonLiteral !== undefined && nonLiteral !== null) {
Expand All @@ -59,7 +59,7 @@ export = {
const expected = ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"];
const candidateArray = nodeValue.elements as Literal[];
const candidateValues = candidateArray.map(
(candidate: Literal): unknown => candidate.value
(candidate: Literal): unknown => candidate.value,
);

// Check if the expected values is included in the array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { getRuleMetaData } from "../utils";
const reportInternal = (
node: Node,
context: Rule.RuleContext,
converter: ParserWeakMapESTreeToTSNode
converter: ParserWeakMapESTreeToTSNode,
): void => {
const tsNode = converter.get(node as TSESTree.Node);
if (!canHaveModifiers(tsNode)) {
Expand Down Expand Up @@ -60,7 +60,7 @@ const reportInternal = (
export = {
meta: getRuleMetaData(
"ts-doc-internal-private-member",
"requires TSDoc comments to not include an '@internal' tag if the object is private"
"requires TSDoc comments to not include an '@internal' tag if the object is private",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const parserServices = context.sourceCode.parserServices as ParserServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const reportInternal = (
node: Node,
context: Rule.RuleContext,
converter: ParserWeakMapESTreeToTSNode,
typeChecker: TypeChecker
typeChecker: TypeChecker,
): void => {
const tsNode = converter.get(node as TSESTree.Node) as any;
const symbol = typeChecker.getTypeAtLocation(tsNode).getSymbol();
Expand All @@ -45,7 +45,7 @@ const reportInternal = (
TSDocTags = TSDocTags.concat(
TSDocComment.tags !== undefined
? TSDocComment.tags.map((TSDocTag: any): string => TSDocTag.tagName.escapedText)
: []
: [],
);
});

Expand Down Expand Up @@ -83,8 +83,8 @@ try {
typeDoc.exclude.forEach((excludedGlob: string): void => {
exclude = exclude.concat(
globSync(excludedGlob).filter(
(excludeFile: string): boolean => !/node_modules/.test(excludeFile)
)
(excludeFile: string): boolean => !/node_modules/.test(excludeFile),
),
);
});
}
Expand All @@ -95,7 +95,7 @@ try {
export = {
meta: getRuleMetaData(
"ts-doc-internal",
"require TSDoc comments to include an '@internal' or '@hidden' tag if the object is not public-facing"
"require TSDoc comments to include an '@internal' or '@hidden' tag if the object is not public-facing",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const fileName = context.filename;
Expand Down Expand Up @@ -128,7 +128,7 @@ export = {

// container declarations
":matches(TSInterfaceDeclaration, ClassDeclaration, TSModuleDeclaration)": (
node: Node
node: Node,
): void => reportInternal(node, context, converter, typeChecker),

// standalone functions
Expand All @@ -138,7 +138,7 @@ export = {
.getAncestors(node)
.every(
(ancestor: Node): boolean =>
!["ClassBody", "TSInterfaceBody", "TSModuleBlock"].includes(ancestor.type)
!["ClassBody", "TSInterfaceBody", "TSModuleBlock"].includes(ancestor.type),
)
) {
reportInternal(node, context, converter, typeChecker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getRuleMetaData } from "../utils";
export = {
meta: getRuleMetaData(
"ts-error-handling",
"limit thrown errors to ECMAScript built-in error types (TypeError, RangeError, Error)"
"limit thrown errors to ECMAScript built-in error types (TypeError, RangeError, Error)",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
/src/.test(context.filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getRuleMetaData } from "../utils";
export = {
meta: getRuleMetaData(
"ts-modules-only-named",
"force there to be only named exports at the top level"
"force there to be only named exports at the top level",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
relative(normalize(context.filename), normalize(context.settings.main)) === ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TSESTree } from "@typescript-eslint/experimental-utils";
export = {
meta: getRuleMetaData(
"ts-naming-drop-noun",
"require client methods returning an instance of the client to not include the client name in the method name"
"require client methods returning an instance of the client to not include the client name in the method name",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
({
Expand Down Expand Up @@ -56,5 +56,5 @@ export = {
}
});
},
} as Rule.RuleListener),
}) as Rule.RuleListener,
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Rule } from "eslint";
export = {
meta: getRuleMetaData(
"ts-naming-options",
"require client method option parameter type names to be suffixed with Options and prefixed with the method name"
"require client method option parameter type names to be suffixed with Options and prefixed with the method name",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const parserServices = context.sourceCode.parserServices as ParserServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TSESTree } from "@typescript-eslint/experimental-utils";
export = {
meta: getRuleMetaData(
"ts-naming-subclients",
"require client methods returning a subclient to have names prefixed suffixed with 'get' and suffixed with 'client'"
"require client methods returning a subclient to have names prefixed suffixed with 'get' and suffixed with 'client'",
),
create: (context: Rule.RuleContext): Rule.RuleListener =>
({
Expand Down Expand Up @@ -54,5 +54,5 @@ export = {
}
});
},
} as Rule.RuleListener),
}) as Rule.RuleListener,
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export = {
});
}
},
} as Rule.RuleListener),
}) as Rule.RuleListener,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export = {
fixer.replaceTextRange([node.range[0], node.range[0] + "window".length], "self"),
});
},
} as Rule.RuleListener),
}) as Rule.RuleListener,
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export = {
meta: getRuleMetaData(
"ts-package-json-author",
"force package.json's author value to be 'Microsoft Corporation'",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export = {
meta: getRuleMetaData(
"ts-package-json-bugs",
"force package.json's bugs.url value to be 'https://github.com/Azure/azure-sdk-for-js/issues'",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
},
},
},
]
],
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const options = context.options[0] || {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export = {
meta: getRuleMetaData(
"ts-package-json-files-required",
"requires package.json's files value to contain paths to the package contents",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand All @@ -71,7 +71,7 @@ export = {
"ExpressionStatement > ObjectExpression": verifiers.existsInFile,

"ExpressionStatement > ObjectExpression > Property[key.value='files']": (
node: Property
node: Property,
): void => {
// check that files is set to an array
if (node.value.type !== "ArrayExpression") {
Expand All @@ -93,7 +93,7 @@ export = {

const nodeValue = node.value;
let filesList = (nodeValue.elements as Literal[]).map(
(element): unknown => element.value
(element): unknown => element.value,
);

const currBadPatterns: string[] = [];
Expand All @@ -111,7 +111,7 @@ export = {
const deletedItemsCount = 1;
currRequiredPatterns.splice(
currRequiredPatterns.indexOf(patternRoot),
deletedItemsCount
deletedItemsCount,
);
}
}
Expand All @@ -126,7 +126,7 @@ export = {
currBadPatterns.length === unitLength ? "is" : "are"
} included in files`;
filesList = filesList.filter(
(filePattern) => currBadPatterns.indexOf(filePattern as string) < 0
(filePattern) => currBadPatterns.indexOf(filePattern as string) < 0,
);
}
// If there are required patterns missing from the files' list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Rule } from "eslint";
export = {
meta: getRuleMetaData(
"ts-package-json-homepage",
"force package.json's homepage value to be a URL pointing to your library's readme inside the git repo"
"force package.json's homepage value to be a URL pointing to your library's readme inside the git repo",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand All @@ -32,13 +32,13 @@ export = {

// check the node corresponding to homepage to see if its value is a URL pointing to your library's readme inside the git repo
"ExpressionStatement > ObjectExpression > Property[key.value='homepage']": (
node: Property
node: Property,
): void => {
const nodeValue = node.value as Literal;

if (
!/^https:\/\/github.com\/Azure\/azure-sdk-for-js\/(blob|tree)\/main\/sdk\/(([a-z]+-)*[a-z]+\/)+(README\.md)?$/.test(
nodeValue.value as string
nodeValue.value as string,
)
) {
context.report({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export = {
meta: getRuleMetaData(
"ts-package-json-keywords",
"force package.json's keywords value to contain at least 'Azure' and 'cloud'",
"code"
"code",
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
Expand Down
Loading

0 comments on commit 12b4dcc

Please sign in to comment.