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 2d1cf48 commit 72b3a0c
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 37 deletions.
175 changes: 169 additions & 6 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v6.0.0 2020-08-10

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

## v5.0.3 2019-12-25

Expand Down
5 changes: 5 additions & 0 deletions examples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends:
- ../.eslintrc.yml
parserOptions:
project: examples/tsconfig.json
sourceType: module
4 changes: 2 additions & 2 deletions examples/websocket-client-promise-ts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env ts-node

import PromiseDuplex from "../src/promise-duplex"

import SimpleWebsocket from "simple-websocket"

import PromiseDuplex from "../src/promise-duplex"

async function main(): Promise<void> {
const ws = new PromiseDuplex(new SimpleWebsocket({url: "ws://echo.websocket.org"}))
const request = process.argv[2] || "Hello, world!"
Expand Down
4 changes: 2 additions & 2 deletions examples/websocket-client-promise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

const {PromiseDuplex} = require("../lib/promise-duplex")

const SimpleWebsocket = require("simple-websocket")

const {PromiseDuplex} = require("../lib/promise-duplex")

async function main() {
const ws = new PromiseDuplex(new SimpleWebsocket({url: "ws://echo.websocket.org"}))
const request = process.argv[2] || "Hello, world!"
Expand Down
22 changes: 15 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.22",
"@types/simple-websocket": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/eslint-plugin-tslint": "^3.9.0",
"@typescript-eslint/parser": "^3.9.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 @@ -51,8 +55,6 @@
"simple-websocket": "^8.1.1",
"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",
"websocket-stream": "^5.5.0"
},
Expand All @@ -61,7 +63,13 @@
"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
2 changes: 1 addition & 1 deletion src/promise-duplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import "core-js/modules/es.symbol.async-iterator"

import {Duplex} from "stream"
import {PromiseReadable} from "promise-readable"
import {PromiseWritable} from "promise-writable"
import {Duplex} from "stream"

interface DuplexStream extends Duplex {
closed?: boolean
Expand Down
5 changes: 5 additions & 0 deletions test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends:
- ../.eslintrc.yml
parserOptions:
project: test/tsconfig.json
sourceType: module
4 changes: 2 additions & 2 deletions test/promise-duplex-async-iterator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {expect} from "chai"

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature("Test promise-duplex module for async iterator", () => {
Scenario("Read chunks from stream", () => {
let iterator: AsyncIterableIterator<string | Buffer>
Expand Down
4 changes: 2 additions & 2 deletions test/promise-duplex-end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import chai, {expect} from "chai"
import dirtyChai from "dirty-chai"
chai.use(dirtyChai)

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature("Test promise-duplex module for end method", () => {
Scenario("End the stream", () => {
let ended = false
Expand Down
4 changes: 2 additions & 2 deletions test/promise-duplex-iterate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {expect} from "chai"

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature("Test promise-duplex module for iterate method", () => {
Scenario("Read chunks from stream", () => {
let iterator: AsyncIterableIterator<string | Buffer>
Expand Down
4 changes: 2 additions & 2 deletions test/promise-duplex-once-end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import chai, {expect} from "chai"
import dirtyChai from "dirty-chai"
chai.use(dirtyChai)

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature('Test promise-duplex module for once("end") method', () => {
Scenario("Wait for end from stream", () => {
let ended = false
Expand Down
4 changes: 2 additions & 2 deletions test/promise-duplex-once.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import chai, {expect} from "chai"
import dirtyChai from "dirty-chai"
chai.use(dirtyChai)

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

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

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature("Test promise-duplex module for readAll method", () => {
Scenario("Read all from stream", () => {
let content: string | Buffer | undefined
Expand Down
4 changes: 2 additions & 2 deletions test/promise-duplex-read.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {expect} from "chai"

import {PromiseDuplex} from "../src/promise-duplex"

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

import {MockStreamDuplex} from "./lib/mock-stream-duplex"

import {PromiseDuplex} from "../src/promise-duplex"

Feature("Test promise-duplex module for read method", () => {
Scenario("Read chunks from stream", () => {
let chunk: string | Buffer | undefined
Expand Down

0 comments on commit 72b3a0c

Please sign in to comment.