Skip to content

Commit

Permalink
Migrate eslint to biome, fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Aug 8, 2024
1 parent 56b53ea commit 89ff43a
Show file tree
Hide file tree
Showing 96 changed files with 1,374 additions and 3,481 deletions.
255 changes: 0 additions & 255 deletions .eslintrc.json

This file was deleted.

7 changes: 5 additions & 2 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ jobs:
- name: Yarn install
run: yarn install

- name: Static code analysis
run: yarn run lint
- name: Lint TypeScript
run: yarn run lint-ts

- name: Lint Markdown
run: yarn run lint-md

- name: Build
run: yarn run build
Expand Down
53 changes: 53 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"correctness": {
"noConstantCondition": "warn"
},
"style": {
"noParameterAssign": "off"
},
"recommended": true,
"complexity": {
"noForEach": "off"
},
"suspicious": {
"noEmptyBlockStatements": "error",
"noControlCharactersInRegex": "off"
},
"nursery": {
"noRestrictedImports": {
"level": "error",
"options": {
"paths": {
"node:buffer": "Use Uint8Array instead of Buffer"
}
}
},
"useConsistentBuiltinInstantiation": "error",
"useThrowNewError": "error",
"useThrowOnlyError": "error",
"useErrorMessage": "error"
}
}
},
"files": {
"ignoreUnknown": true,
"ignore": [
"./coverage",
"./yarn",
"./lib/**/*.d.ts",
"./lib/**/*.js",
"./test/**/*.d.ts",
"./test/**/*.js"
]
}
}
8 changes: 4 additions & 4 deletions doc-gen/MarkDown.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
import type * as fs from 'node:fs';

export class Row {
constructor(public values: string[]) {
Expand All @@ -7,7 +7,7 @@ export class Row {

export class Table {

private static padEnd(value: string, size: number, pad: string = ' ') {
private static padEnd(value: string, size: number, pad = ' ') {
while (value.length < size) {
value += pad;
}
Expand All @@ -20,13 +20,13 @@ export class Table {
const cellTxt = values.length > ci ? values[ci] : '';
colValues.push(Table.padEnd(cellTxt, colSizes[ci]));
}
out.write('| ' + colValues.join(' | ') + ' |\n');
out.write(`| ${colValues.join(' | ')} |\n`);
}

private static lineToString(colSizes: number[]): string {

const colValues = colSizes.map(size => Table.padEnd('-', size, '-'));
return '|-' + colValues.join('-|-') + '-|\n';
return `|-${colValues.join('-|-')}-|\n`;
}

public rows: Row[] = [];
Expand Down
4 changes: 2 additions & 2 deletions doc-gen/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function getNativeSourceTags(nativeType: string, commonTag: string): string[] {

function write(out: fs.WriteStream) {

const json = fs.readFileSync(path.join(dirname, 'common.json'));
const commonDescriptionDict: ITagInfoDict = JSON.parse(json as any);
const json = fs.readFileSync(path.join(dirname, 'common.json'), {encoding: 'utf-8'});
const commonDescriptionDict: ITagInfoDict = JSON.parse(json);

const table = new markDown.Table();

Expand Down
2 changes: 1 addition & 1 deletion example/javascript/orderTags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseFile, orderTags } from '../../lib/index.js'; // music-metadata
import { inspect } from 'util';
import { inspect } from 'node:util';

(async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion example/javascript/parseFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseFile } from '../../lib/index.js'; // music-metadata
import { inspect } from 'util';
import { inspect } from 'node:util';

(async () => {
try {
Expand Down
6 changes: 3 additions & 3 deletions example/javascript/stream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import https from 'https';
import { inspect } from 'util';
import https from 'node:https';
import { inspect } from 'node:util';
import { parseStream } from '../../lib/index.js'; // music-metadata

const audioUrl = 'https://github.com/Borewit/music-metadata/raw/master/test/samples/MusicBrainz%20-%20Beth%20Hart%20-%20Sinner\'s%20Prayer%20%5Bid3v2.3%5D.V2.mp3';
Expand All @@ -15,7 +15,7 @@ function httpGet (url) {
resolve(httpGet(res.headers.location));
break;
default:
reject(new Error('Unexpected status-code:' + res.statusCode));
reject(new Error(`Unexpected status-code:${res.statusCode}`));
}
});
});
Expand Down
Loading

0 comments on commit 89ff43a

Please sign in to comment.