Skip to content

Commit

Permalink
chore: set noUncheckedIndexedAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Jan 17, 2024
1 parent 3e2ac7f commit 098e82b
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/embedded/html/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const embedder: Embedder<Options> = async (
const parts = [];
const components = doc.split(placeholderRegex);
for (let i = 0; i < components.length; i++) {
let component = components[i];
let component = components[i]!;
if (i % 2 == 0) {
if (!component) {
continue;
Expand All @@ -65,7 +65,7 @@ export const embedder: Embedder<Options> = async (
parts.push(component);
} else {
const placeholderIndex = Number(component);
parts.push(expressionDocs[placeholderIndex]);
parts.push(expressionDocs[placeholderIndex]!);
}
}
return parts;
Expand Down
4 changes: 2 additions & 2 deletions src/embedded/sh/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const embedder: Embedder<Options> = async (
const parts = [];
const components = doc.split(placeholderRegex);
for (let i = 0; i < components.length; i++) {
let component = components[i];
let component = components[i]!;
if (i % 2 == 0) {
if (!component) {
continue;
Expand All @@ -64,7 +64,7 @@ export const embedder: Embedder<Options> = async (
.forEach((c) => (c === "\n" ? parts.push(hardline) : parts.push(c)));
} else {
const placeholderIndex = Number(component);
parts.push(expressionDocs[placeholderIndex]);
parts.push(expressionDocs[placeholderIndex]!);
}
}
return parts;
Expand Down
4 changes: 2 additions & 2 deletions src/embedded/sql/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const embedder: Embedder<Options> = async (
const parts = [];
const components = doc.split(placeholderRegex);
for (let i = 0; i < components.length; i++) {
let component = components[i];
let component = components[i]!;
if (i % 2 == 0) {
if (!component) {
continue;
Expand All @@ -84,7 +84,7 @@ export const embedder: Embedder<Options> = async (
);
} else {
const placeholderIndex = Number(component);
parts.push(expressionDocs[placeholderIndex]);
parts.push(expressionDocs[placeholderIndex]!);
}
}
return parts;
Expand Down
4 changes: 2 additions & 2 deletions src/embedded/toml/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const embedder: Embedder<Options> = async (
const parts = [];
const components = doc.split(placeholderRegex);
for (let i = 0; i < components.length; i++) {
let component = components[i];
let component = components[i]!;
if (i % 2 == 0) {
if (!component) {
continue;
Expand All @@ -70,7 +70,7 @@ export const embedder: Embedder<Options> = async (
.forEach((c) => (c === "\n" ? parts.push(hardline) : parts.push(c)));
} else {
const placeholderIndex = Number(component);
parts.push(expressionDocs[placeholderIndex]);
parts.push(expressionDocs[placeholderIndex]!);
}
}
return parts;
Expand Down
6 changes: 3 additions & 3 deletions src/embedded/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function simpleRehydrateDoc(
const parts = [];
const components = doc.split(placeholderRegex);
for (let i = 0; i < components.length; i++) {
let component = components[i];
let component = components[i]!;
if (i % 2 == 0) {
if (!component) {
continue;
Expand All @@ -49,7 +49,7 @@ export function simpleRehydrateDoc(
parts.push(component);
} else {
const placeholderIndex = Number(component);
parts.push(expressionDocs[placeholderIndex]);
parts.push(expressionDocs[placeholderIndex]!);
}
}
return parts;
Expand Down Expand Up @@ -95,7 +95,7 @@ export function insertLanguage(
languages.push(language);
return;
}
if (languages[mid] < language) {
if (languages[mid]! < language) {
low = mid + 1;
} else {
high = mid;
Expand Down
4 changes: 2 additions & 2 deletions src/embedded/xml/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const parser: Parser<CstNode> = {

// If there are any lexical errors, throw the first of them as an error.
if (lexErrors.length > 0) {
const lexError = lexErrors[0];
const lexError = lexErrors[0]!;
throw createSyntaxErrorFromLexError(lexError);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ function pruneCst(cstNode: CstNode) {
for (const name in cstNodeChildren) {
const cstElements = cstNodeChildren[name] ?? [];
for (let i = cstElements.length - 1; i >= 0; --i) {
const cstElement = cstElements[i];
const cstElement = cstElements[i]!;
if (!isCstNode(cstElement)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/printers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const embed: Printer["embed"] = function (
return null;
}
const node = path.node as TemplateLiteral;
if (node.quasis.length === 1 && node.quasis[0].value.raw.trim() === "") {
if (node.quasis.length === 1 && node.quasis[0]?.value.raw.trim() === "") {
return "``";
}
return async (textToDoc, print, path, options) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function getIdentifierFromComment(
if (!nodeComments) {
return;
}
const lastNodeComment = nodeComments[nodeComments.length - 1];
const lastNodeComment = nodeComments[nodeComments.length - 1]!;
if (
![
"MultiLine", // meriyah
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true
},
"include": ["./src", "./tests"],
"references": [
Expand Down

0 comments on commit 098e82b

Please sign in to comment.