Content-Length: 614103 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/11355/files

35 fix(typescript-estree): if the template literal is tagged and the text has an invalid escape, `cooked` will be `null` by nayounsang · Pull Request #11355 · typescript-eslint/typescript-eslint · GitHub
Skip to content

fix(typescript-estree): if the template literal is tagged and the text has an invalid escape, cooked will be null #11355

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 0 additions & 4 deletions .github/actions/prepare-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ runs:
shell: bash
run: |
yarn nx run types:build
env:
SKIP_AST_SPEC_REBUILD: true

- name: Build
if: steps['build-cache'].outputs.cache-hit != 'true'
shell: bash
# Website will be built by the Netlify GitHub App
run: |
yarn nx run-many --target=build --parallel --exclude=website --exclude=website-eslint
env:
SKIP_AST_SPEC_REBUILD: true

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ast-spec/src/special/TemplateElement/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface TemplateElement extends BaseNode {
type: AST_NODE_TYPES.TemplateElement;
tail: boolean;
value: {
cooked: string;
cooked: string | null;
raw: string;
};
}
1 change: 1 addition & 0 deletions packages/ast-spec/tests/fixtures-with-differences-ast.shot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ export default createRule<Options, MessageIds>({

const text = literal.quasis[0].value.cooked;

if (text == null) {
return;
}

if (literal.loc.end.line === literal.loc.start.line) {
// don't use template strings for single line tests
return context.report({
Expand Down Expand Up @@ -448,9 +452,13 @@ export default createRule<Options, MessageIds>({
}

function checkForUnnecesaryNoFormat(
text: string,
text: string | null,
expr: TSESTree.TaggedTemplateExpression,
): void {
if (text == null) {
return;
}

const formatted = getCodeFormatted(text);
if (formatted === text) {
context.report({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default createRule({
return;
}

let value: number | string | undefined;
let value: number | string | null | undefined;
if (isStringLiteral(member.initializer)) {
value = member.initializer.value;
} else if (isNumberLiteral(member.initializer)) {
Expand Down
6 changes: 5 additions & 1 deletion packages/eslint-plugin/src/rules/no-unsafe-assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ export default createRule({
receiverProperty.key.type === AST_NODE_TYPES.TemplateLiteral &&
receiverProperty.key.quasis.length === 1
) {
key = receiverProperty.key.quasis[0].value.cooked;
const cooked = receiverProperty.key.quasis[0].value.cooked;
if (cooked == null) {
continue;
}
key = cooked;
} else {
// can't figure out the name, so skip it
continue;
Expand Down
3 changes: 3 additions & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
],
"targets": {
"build": {
"inputs": [
"{projectRoot}/src/generated"
],
"dependsOn": [
"copy-ast-spec"
]
Expand Down
Loading
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/11355/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy