Skip to content

Commit

Permalink
chore(deps): upgrade biome and esbuild
Browse files Browse the repository at this point in the history
- Fix reported code
- Disable `noUselessLoneBlockStatemens`
  • Loading branch information
Conaclos committed Oct 19, 2023
1 parent 5a2f848 commit a5efc47
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 154 deletions.
7 changes: 5 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
"linter": {
"rules": {
"all": true,
"complexity": {
"noExcessiveCognitiveComplexity": "off"
},
"nursery": {
"all": true,
"noExcessiveComplexity": "off",
"noUselessLoneBlockStatements": "off",
"useImportRestrictions": "off"
},
"style": {
Expand All @@ -19,7 +22,7 @@
},
"javascript": {
"formatter": {
"indentSize": 4,
"indentWidth": 4,
"semicolons": "asNeeded"
}
},
Expand Down
244 changes: 124 additions & 120 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
},
"devDependencies": {
"@bare-ts/lib": "~0.4.0",
"@biomejs/biome": "1.2.1",
"@biomejs/biome": "1.3.0",
"@types/node": "16.9.6",
"esbuild": "0.19.3",
"esbuild": "0.19.5",
"oletus": "4.0.0",
"rome": "12.1.3",
"typescript": "5.2.2",
Expand Down
3 changes: 2 additions & 1 deletion src/ast/bare-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ export function rootAliases(defs: readonly AliasedType[]): readonly string[] {
function referredAliases(type: Type): readonly string[] {
if (type.tag === "alias") {
return [type.data]
} else if (type.types != null) {
}
if (type.types != null) {
return type.types.flatMap((t) => referredAliases(t))
}
return []
Expand Down
9 changes: 6 additions & 3 deletions src/ast/bare-semantic-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ function checkUsedBeforeDefined(
`Alias '${type.data}' is used before its definition. To allow use-before-definition and recursive types set the option '--legacy'.`,
type.offset,
)
} else if (type.types != null) {
}
if (type.types != null) {
for (const subtype of type.types) {
checkUsedBeforeDefined(c, subtype, defined)
}
Expand All @@ -313,7 +314,8 @@ function checkCircularRef(
type.tag === "optional"
) {
return // allowed circular refs
} else if (type.tag === "union") {
}
if (type.tag === "union") {
let circularCount = 0
let firstError: CompilerError | null = null
for (const subtype of type.types) {
Expand All @@ -330,7 +332,8 @@ function checkCircularRef(
throw firstError
}
return // allowed circular refs
} else if (type.tag === "struct" || type.tag === "list") {
}
if (type.tag === "struct" || type.tag === "list") {
for (const subtype of type.types) {
checkCircularRef(c, subtype, traversed)
}
Expand Down
3 changes: 2 additions & 1 deletion src/generator/bare-ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function innerUnrecursive(
const extra = type.extra
if (simplified == null) {
return { tag: "void", data: null, types: null, extra, offset: 0 }
} else if (type.types[0] !== simplified) {
}
if (type.types[0] !== simplified) {
return simplifyOptional({
tag: "optional",
data: null,
Expand Down
33 changes: 15 additions & 18 deletions src/generator/js-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function genAliasedType(g: Gen, aliased: ast.AliasedType): string {
if (!isClass) {
const structDef = genStructType(g, type)
return `${doc}export type ${alias} = ${structDef}`
} else if (g.config.generator !== "dts") {
}
if (g.config.generator !== "dts") {
return "" // A non-ambient class will be generated
}
return dent`
Expand Down Expand Up @@ -174,9 +175,8 @@ function genType(g: Gen, type: ast.Type): string {
}
if (type.extra?.safe) {
return `${type.tag}Safe`
} else {
return type.tag
}
return type.tag
}

function genAliasType(g: Gen, type: ast.Alias): string {
Expand All @@ -193,11 +193,11 @@ function genListType(g: Gen, type: ast.ListType): string {
const typedArray = ast.FIXED_NUMERIC_TYPE_TO_TYPED_ARRAY.get(valType.tag)
if (type.extra?.typedArray && typedArray != null) {
return global(g, typedArray)
} else if (type.extra?.unique) {
}
if (type.extra?.unique) {
return genSetType(g, type)
} else {
return genListRawType(g, type)
}
return genListRawType(g, type)
}

function genListRawType(g: Gen, type: ast.ListType): string {
Expand Down Expand Up @@ -242,9 +242,8 @@ function genOptionalType(g: Gen, type: ast.OptionalType): string {
if (simplified.tag === "optional") {
const typedef = genType(g, simplified.types[0])
return `${typedef} | ${noneVal(simplified)}`
} else {
return genType(g, simplified)
}
return genType(g, simplified)
}

function genMapType(g: Gen, type: ast.MapType): string {
Expand Down Expand Up @@ -467,19 +466,18 @@ function genReader(g: Gen, type: ast.Type, alias = ""): string {
}
if (type.extra?.safe) {
return `(bare.read${capitalize(type.tag)}Safe(bc))`
} else {
return `(bare.read${capitalize(type.tag)}(bc))`
}
return `(bare.read${capitalize(type.tag)}(bc))`
}

function genListReader(g: Gen, type: ast.ListType): string {
if (type.extra?.typedArray) {
return genTypedArrayReader(g, type)
} else if (type.extra?.unique) {
}
if (type.extra?.unique) {
return genSetReader(g, type)
} else {
return genListRawReader(g, type)
}
return genListRawReader(g, type)
}

function genListRawReader(g: Gen, type: ast.ListType): string {
Expand Down Expand Up @@ -767,19 +765,18 @@ function genWriter(g: Gen, type: ast.Type, alias = ""): string {
}
if (type.extra?.safe) {
return `(bare.write${capitalize(type.tag)}Safe(bc, $x))`
} else {
return `(bare.write${capitalize(type.tag)}(bc, $x))`
}
return `(bare.write${capitalize(type.tag)}(bc, $x))`
}

function genListWriter(g: Gen, type: ast.ListType): string {
if (type.extra?.typedArray) {
return genTypedArrayWriter(g, type)
} else if (type.extra?.unique) {
}
if (type.extra?.unique) {
return genSetWriter(g, type)
} else {
return genListRawWriter(g, type)
}
return genListRawWriter(g, type)
}

function genListRawWriter(g: Gen, type: ast.ListType): string {
Expand Down
7 changes: 4 additions & 3 deletions src/parser/bare-lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ export function nextToken(lex: Lexer): void {
}
}
offset++
} else if (PUNCTUATION_PATTERN.test(c)) {
token = c
break
} else {
if (PUNCTUATION_PATTERN.test(c)) {
token = c
break
}
const suffix = content.slice(offset)
const match = suffix.match(ID_PATTERN)
if (match == null) {
Expand Down
6 changes: 2 additions & 4 deletions src/parser/bare-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ function parseTypeName(p: Parser): ast.Type {
const tag = alias === "string" ? "str" : alias
if (ast.isBaseTag(tag) || tag === "void") {
return { tag, data: null, types: null, extra: null, offset }
} else {
return { tag: "alias", data: alias, types: null, extra: null, offset }
}
return { tag: "alias", data: alias, types: null, extra: null, offset }
}

function parseData(p: Parser): ast.Type {
Expand Down Expand Up @@ -379,9 +378,8 @@ function parseOptionalLength(p: Parser): ast.Length | null {
const val = parseUnsignedNumber(p)
expect(p, "]")
return { name: null, val, comment: null, extra: null, offset }
} else {
return null
}
return null
}

function parseTypeParameter(p: Parser): ast.Type {
Expand Down

0 comments on commit a5efc47

Please sign in to comment.