Skip to content

Commit

Permalink
Converted from tslint to eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Aug 10, 2020
1 parent 6bc9ffb commit 6ccb08a
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 51 deletions.
175 changes: 169 additions & 6 deletions .eslintrc.yml
@@ -1,9 +1,172 @@
# npm i -g eslint eslint-config-prettier eslint-plugin-import eslint-plugin-node

env:
es6: true
node: true

extends: prettier

extends:
- prettier
- prettier/@typescript-eslint
ignorePatterns:
- coverage/**
- lib/**
overrides:
- files:
- "**/*.ts"
parser: "@typescript-eslint/parser"
parserOptions:
project: tsconfig.json
sourceType: module
rules:
"@typescript-eslint/adjacent-overload-signatures": error
"@typescript-eslint/array-type":
- error
- default: array-simple
"@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/consistent-type-definitions": error
"@typescript-eslint/dot-notation": error
"@typescript-eslint/explicit-member-accessibility":
- error
- accessibility: no-public
"@typescript-eslint/member-delimiter-style":
- off
- multiline:
delimiter: none
requireLast: true
singleline:
delimiter: semi
requireLast: false
"@typescript-eslint/member-ordering": error
"@typescript-eslint/naming-convention": error
"@typescript-eslint/no-empty-function": error
"@typescript-eslint/no-empty-interface": error
"@typescript-eslint/no-explicit-any": off
"@typescript-eslint/no-misused-new": error
"@typescript-eslint/no-namespace": off
"@typescript-eslint/no-parameter-properties": off
"@typescript-eslint/no-unused-expressions": error
"@typescript-eslint/no-use-before-define": off
"@typescript-eslint/no-var-requires": error
"@typescript-eslint/prefer-for-of": error
"@typescript-eslint/prefer-function-type": error
"@typescript-eslint/prefer-namespace-keyword": error
"@typescript-eslint/semi":
- off
- null
"@typescript-eslint/triple-slash-reference":
- error
- path: always
types: prefer-import
lib: always
"@typescript-eslint/unified-signatures": error
parser: espree
parserOptions:
ecmaVersion: 2017
ecmaVersion: 2018
sourceType: module
plugins:
- "@typescript-eslint"
- import
- jsdoc
rules:
arrow-body-style: error
arrow-parens:
- off
- always
brace-style:
- off
- off
complexity: 0
constructor-super: error
curly:
- error
- multi-line
eqeqeq:
- error
- smart
guard-for-in: error
id-blacklist: 0
id-match: error
import/order: error
jsdoc/check-alignment: error
jsdoc/check-indentation: error
jsdoc/newline-after-description: error
max-classes-per-file:
- error
- 1
no-bitwise: error
no-caller: error
no-cond-assign: 0
no-console:
- error
- allow:
- warn
- dir
- time
- timeEnd
- timeLog
- trace
- assert
- clear
- count
- countReset
- group
- groupEnd
- table
- debug
- info
- dirxml
- error
- groupCollapsed
- Console
- profile
- profileEnd
- timeStamp
- context
no-debugger: error
no-empty: error
no-eval: error
no-fallthrough: 0
no-invalid-this: 0
no-irregular-whitespace: 0
no-new-wrappers: error
no-shadow:
- error
- hoist: all
no-throw-literal: error
no-undef-init: error
no-underscore-dangle: 0
no-unsafe-finally: error
no-unused-labels: error
no-var: error
object-shorthand: error
one-var:
- error
- never
prefer-const: error
radix: error
react/jsx-curly-spacing: off
react/jsx-equals-spacing: off
react/jsx-wrap-multilines: off
space-in-parens:
- off
- never
spaced-comment:
- error
- always
- markers:
- /
use-isnan: error
valid-typeof: 0
1 change: 0 additions & 1 deletion .mocharc.yml
@@ -1,6 +1,5 @@
color: true
diff: true
opts: ./test/mocha.opts
package: ./package.json
require:
- ts-node/register
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## v6.0.0 2020-08-09

- Requires Node >= 10.
- Converted from tslint to eslint.

## v5.0.4 2019-12-25

Expand Down
5 changes: 5 additions & 0 deletions examples/.eslintrc.yml
@@ -0,0 +1,5 @@
extends:
- ../.eslintrc.yml
parserOptions:
project: examples/tsconfig.json
sourceType: module
22 changes: 15 additions & 7 deletions package.json
Expand Up @@ -29,15 +29,19 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.22",
"@types/semver": "^6.2.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/eslint-plugin-tslint": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"chai": "^4.2.0",
"changelog-parser": "^2.8.0",
"coveralls": "^3.0.9",
"cross-env": "^6.0.3",
"dirty-chai": "^2.0.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.8.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^10.0.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsdoc": "^30.2.1",
"eslint-plugin-node": "^11.1.0",
"markdownlint-cli": "^0.20.0",
"mocha": "^6.2.2",
"mocha-steps": "^1.3.0",
Expand All @@ -47,16 +51,20 @@
"shx": "^0.3.2",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.4"
},
"scripts": {
"compile": "tsc --pretty --project .",
"clean": "npm run clean:compile && npm run clean:coverage",
"clean:compile": "shx rm -rf lib",
"clean:coverage": "shx rm -rf coverage .nyc_output",
"lint": "npm run compile && tsc --pretty -p examples && tsc --pretty -p test && eslint . && tslint -t stylish -p . && tslint -t stylish -p examples && tslint -t stylish -p test && prettier --ignore-path .gitignore --list-different '**/*.{js,json,md,ts,yml}' && markdownlint \"*.md\"",
"lint": "npm run lint:tsc:src && npm run lint:tsc:test && npm run lint:tsc:examples && npm run lint:eslint && npm run lint:prettier && npm run lint:markdownlint",
"lint:tsc:examples": "tsc --noEmit --pretty --project examples",
"lint:tsc:src": "tsc --noEmit --pretty --project .",
"lint:tsc:test": "tsc --noEmit --pretty --project test",
"lint:eslint": "eslint --ext .js,.ts .",
"lint:prettier": "prettier --ignore-path .gitignore --list-different '**/*.{js,json,md,ts,yml}'",
"lint:markdownlint": "markdownlint \"*.md\"",
"postpublish": "node -e \"require(\\\"changelog-parser\\\")(\\\"CHANGELOG.md\\\").then(ch => console.log(ch.versions.filter(v => v.version === \\\"$npm_package_version\\\").map(v => \\\"v$npm_package_version\\n\\n\\\" + v.body).concat(\\\"Release v$npm_package_version\\\")[0]))\" | xargs -0 git tag v$npm_package_version -a -m && git push --tags",
"prepack": "npm run compile",
"prepublishOnly": "npm run test",
Expand Down
5 changes: 3 additions & 2 deletions renovate.json
@@ -1,11 +1,12 @@
{
"extends": [
"config:base",
"group:allNonMajor",
"group:definitelyTyped",
"group:linters",
"group:monorepos",
"group:testNonMajor"
"group:testNonMajor",
"group:typescript-eslintMonorepo",
"group:allNonMajor"
],
"rangeStrategy": "bump",
"semanticCommits": false
Expand Down
16 changes: 8 additions & 8 deletions src/promise-writable.ts
Expand Up @@ -12,22 +12,18 @@ interface WritableStream extends NodeJS.WritableStream {
}

export class PromiseWritable<TWritable extends WritableStream> {
static [Symbol.hasInstance](instance: PromiseWritable<WritableStream>): boolean {
return instance._isPromiseWritable
}

readonly _isPromiseWritable: boolean = true

_errored?: Error

private errorHandler = (err: Error): void => {
this._errored = err
}

constructor(readonly stream: TWritable) {
stream.on("error", this.errorHandler)
}

static [Symbol.hasInstance](instance: PromiseWritable<WritableStream>): boolean {
return instance._isPromiseWritable
}

write(chunk: string | Buffer, encoding?: string): Promise<number> {
const stream = this.stream

Expand Down Expand Up @@ -295,6 +291,10 @@ export class PromiseWritable<TWritable extends WritableStream> {
}
}
}

private errorHandler = (err: Error): void => {
this._errored = err
}
}

export default PromiseWritable
5 changes: 5 additions & 0 deletions test/.eslintrc.yml
@@ -0,0 +1,5 @@
extends:
- ../.eslintrc.yml
parserOptions:
project: test/tsconfig.json
sourceType: module
4 changes: 2 additions & 2 deletions test/promise-writable-end.ts
Expand Up @@ -3,12 +3,12 @@ import chai, {expect} from "chai"
import dirtyChai from "dirty-chai"
chai.use(dirtyChai)

import {PromiseWritable} from "../src/promise-writable"

import {And, Feature, Given, Scenario, Then, When} from "./lib/steps"

import {MockStreamWritable} from "./lib/mock-stream-writable"

import {PromiseWritable} from "../src/promise-writable"

Feature("Test promise-writable module for end method", () => {
Scenario("End the stream", () => {
let ended = false
Expand Down
7 changes: 4 additions & 3 deletions test/promise-writable-instanceof.ts
@@ -1,14 +1,15 @@
import {PassThrough} from "stream"
import {expect} from "chai"

import semver from "semver"
import {PassThrough} from "stream"

import {PromiseWritable} from "../src/promise-writable"

import {And, Feature, Given, Scenario, Then} from "./lib/steps"

import {MockPromiseDuplex} from "./lib/mock-promise-duplex"
import {MockStreamWritable} from "./lib/mock-stream-writable"

import {PromiseWritable} from "../src/promise-writable"

if (semver.gte(process.version, "6.11.3")) {
Feature("Test promise-writable module with instanceof operator", () => {
Scenario("instanceof operator with MockStream class", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/promise-writable-once-error.ts
@@ -1,11 +1,11 @@
import {expect} from "chai"

import {PromiseWritable} from "../src/promise-writable"

import {And, Feature, Given, Scenario, Then, When} from "./lib/steps"

import {MockStreamWritable} from "./lib/mock-stream-writable"

import {PromiseWritable} from "../src/promise-writable"

Feature('Test promise-writable module for once("error") method', () => {
Scenario("Wait for error from stream with error", () => {
let error: Error
Expand Down
4 changes: 2 additions & 2 deletions test/promise-writable-once.ts
Expand Up @@ -3,12 +3,12 @@ import chai, {expect} from "chai"
import dirtyChai from "dirty-chai"
chai.use(dirtyChai)

import {PromiseWritable} from "../src/promise-writable"

import {And, Feature, Given, Scenario, Then, When} from "./lib/steps"

import {MockStreamWritable} from "./lib/mock-stream-writable"

import {PromiseWritable} from "../src/promise-writable"

Feature("Test promise-writable module for once method", () => {
for (const event of ["open", "close", "pipe", "unpipe", "finish"]) {
Scenario(`Wait for ${event} from stream`, () => {
Expand Down
4 changes: 2 additions & 2 deletions test/promise-writable-write-all.ts
@@ -1,11 +1,11 @@
import {expect} from "chai"

import {PromiseWritable} from "../src/promise-writable"

import {And, Feature, Given, Scenario, Then, When} from "./lib/steps"

import {MockStreamWritable} from "./lib/mock-stream-writable"

import {PromiseWritable} from "../src/promise-writable"

Feature("Test promise-writable module for writeAll method", () => {
Scenario("Write all in one chunk", () => {
let bytes: number
Expand Down

0 comments on commit 6ccb08a

Please sign in to comment.