Skip to content

refactor(material/schematics): fix some typos and add JSDoc #22610

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

Merged
merged 1 commit into from
May 10, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function detectImports(content: string, prefix: string): DetectImportResult {
return {imports, namespaces};
}

/** Migrates the Material symbls in a file. */
/** Migrates the Material symbols in a file. */
function migrateMaterialSymbols(content: string, importPath: string,
detectedImports: DetectImportResult): string {
const initialContent = content;
Expand Down Expand Up @@ -154,6 +154,7 @@ function migrateCdkSymbols(content: string, importPath: string,
* Renames all Sass symbols in a file based on a pre-defined mapping.
* @param content Content of a file to be migrated.
* @param mapping Mapping between symbol names and their replacements.
* @param namespaces Names to iterate over and pass to getKeyPattern.
* @param getKeyPattern Function used to turn each of the keys into a regex.
* @param formatValue Formats the value that will replace any matches of the pattern returned by
* `getKeyPattern`.
Expand Down Expand Up @@ -205,15 +206,15 @@ function insertUseStatement(content: string, importPath: string, importsToIgnore
/** Formats a migration key as a Sass mixin invocation. */
function mixinKeyFormatter(namespace: string|null, name: string): RegExp {
// Note that adding a `(` at the end of the pattern would be more accurate, but mixin
// invocations don't necessarily have to include the parantheses. We could add `[(;]`,
// invocations don't necessarily have to include the parentheses. We could add `[(;]`,
// but then we won't know which character to include in the replacement string.
return new RegExp(`@include +${escapeRegExp((namespace ? namespace + '.' : '') + name)}`, 'g');
}

/** Returns a function that can be used to format a Sass mixin replacement. */
function getMixinValueFormatter(namespace: string): (name: string) => string {
// Note that adding a `(` at the end of the pattern would be more accurate,
// but mixin invocations don't necessarily have to include the parantheses.
// but mixin invocations don't necessarily have to include the parentheses.
return name => `@include ${namespace}.${name}`;
}

Expand Down