Skip to content
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

Align eslint configuration with music-metadata #431

Merged
merged 2 commits into from
Feb 6, 2022
Merged
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
14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

245 changes: 245 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"eslint-plugin-jsdoc",
"eslint-plugin-node",
"eslint-plugin-unicorn",
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"error",
{
"default": "array"
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"Object": {
"message": "Avoid using the `Object` type. Did you mean `object`?"
},
"Function": {
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
},
"Boolean": {
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
},
"Number": {
"message": "Avoid using the `Number` type. Did you mean `number`?"
},
"String": {
"message": "Avoid using the `String` type. Did you mean `string`?"
},
"Symbol": {
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
}
}
}
],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/indent": [
"error",
2,
{
"ObjectExpression": "first",
"FunctionDeclaration": {
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"
},
"SwitchCase": 1
}
],
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": [
"error",
{
"allow": [
"constructors"
]
}
],
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-shadow": [
"error",
{
"hoist": "all"
}
],
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
"path": "always",
"types": "prefer-import",
"lib": "always"
}
],
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"error",
"as-needed"
],
"comma-dangle": "error",
"complexity": "off",
"constructor-super": "error",
"curly": "off",
"default-case": "off",
"dot-notation": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "off",
"id-denylist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"id-match": "error",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": false
}
],
"import/no-internal-modules": "off",
"import/order": "off",
"import/no-unresolved": ["error", {"caseSensitiveStrict": true }],
"indent": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "error",
"jsdoc/newline-after-description": [
"error",
"never"
],
"max-classes-per-file": "off",
"max-len": [
"error",
{
"code": 200
}
],
"new-parens": "error",
"no-bitwise": "off",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "error",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-empty-function": "off",
"no-eval": "error",
"no-extra-bind": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-use-before-define": "off",
"no-var": "error",
"node/file-extension-in-import": ["off"],
"node/no-extraneous-import": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": [
"error",
"as-needed"
],
"quotes": "off",
"radix": "error",
"semi": "error",
"space-in-parens": [
"error",
"never"
],
"spaced-comment": [
"error",
"always",
{
"markers": [
"/"
]
}
],
"unicorn/prefer-ternary": "error",
"use-isnan": "error",
"valid-typeof": "off"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [
".ts",
".tsx"
]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": [
"lib/tsconfig.json",
"test/tsconfig.json"
]
}
}
}
}

4 changes: 2 additions & 2 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x

- name: Install production dependencies, check node engine compatiblity
run: yarn install --production=true
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 14.x, 16.x, 17.x]

steps:

Expand Down
4 changes: 2 additions & 2 deletions lib/StreamReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class StreamReader {
// continue reading from stream if required
while (remaining > 0 && !this.endOfStream) {
const reqLen = Math.min(remaining, maxStreamReadSize);
const chunkLen = await this._read(buffer, offset + bytesRead, reqLen);
const chunkLen = await this.readFromStream(buffer, offset + bytesRead, reqLen);
bytesRead += chunkLen;
if (chunkLen < reqLen)
break;
Expand All @@ -101,7 +101,7 @@ export class StreamReader {
* @param length Number of bytes to read
* @returns Number of bytes read
*/
private async _read(buffer: Uint8Array, offset: number, length: number): Promise<number> {
private async readFromStream(buffer: Uint8Array, offset: number, length: number): Promise<number> {

const readBuffer = this.s.read(length);

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
"coveralls": "^3.1.1",
"del-cli": "^4.0.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsdoc": "^37.7.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^40.1.0",
"mocha": "^9.2.0",
"nyc": "^15.1.0",
"remark-cli": "^10.0.1",
Expand Down
14 changes: 14 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
ESLint configuration
*/

{
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
}
}
2 changes: 1 addition & 1 deletion test/examples.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:no-console */
/* eslint-disable no-console */

import { assert } from 'chai';
import * as fs from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('StreamReader', () => {
const sourceStream = new SourceStream('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09');
const streamReader = new StreamReader(sourceStream);

const prom: Array<Promise<number>> = [];
const prom: Promise<number>[] = [];

for (let i = 0; i < 10; ++i) {
prom.push(readByteAsNumber(streamReader));
Expand Down
Loading