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 Oct 7, 2020
1 parent cef7652 commit 1f01ed4
Show file tree
Hide file tree
Showing 21 changed files with 265 additions and 100 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
coverage/**
lib/**
out/**
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 eslint-plugin-promise

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": off
"@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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3.0.0 2020-10-07

- Converted from tslint to eslint.

## v2.1.3 2019-10-07

- Use `mocha-steps` for testing.
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/test-fs-gzip-blob-storage-read-ts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env ts-node

import {FsGzipBlobStorage} from "../src/fs-gzip-blob-storage"

import "stream.pipeline-shim/auto"

import stream from "stream"
import util from "util"

import {FsGzipBlobStorage} from "../src/fs-gzip-blob-storage"

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
4 changes: 2 additions & 2 deletions examples/test-fs-gzip-blob-storage-read.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node

const {FsGzipBlobStorage} = require("../lib/fs-gzip-blob-storage")

require("stream.pipeline-shim/auto")

const stream = require("stream")
const util = require("util")

const {FsGzipBlobStorage} = require("../lib/fs-gzip-blob-storage")

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
4 changes: 2 additions & 2 deletions examples/test-fs-gzip-blob-storage-write-ts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env ts-node

import {FsGzipBlobStorage} from "../src/fs-gzip-blob-storage"

import "stream.pipeline-shim/auto"

import stream from "stream"
import util from "util"

import {FsGzipBlobStorage} from "../src/fs-gzip-blob-storage"

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
4 changes: 2 additions & 2 deletions examples/test-fs-gzip-blob-storage-write.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node

const {FsGzipBlobStorage} = require("../lib/fs-gzip-blob-storage")

require("stream.pipeline-shim/auto")

const stream = require("stream")
const util = require("util")

const {FsGzipBlobStorage} = require("../lib/fs-gzip-blob-storage")

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"node": ">=8.0.0"
},
"dependencies": {
"fs-blob-storage": "^2.1.4",
"fs-blob-storage": "^3.0.0",
"pumpify": "^2.0.1",
"tslib": "^1.10.0"
},
Expand All @@ -34,16 +34,19 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.7.11",
"@types/pumpify": "^1.4.1",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"@typescript-eslint/eslint-plugin-tslint": "^4.4.0",
"@typescript-eslint/parser": "^4.4.0",
"chai": "^4.2.0",
"changelog-parser": "^2.8.0",
"coveralls": "^3.0.6",
"cross-env": "^6.0.3",
"dirty-chai": "^2.0.1",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^30.6.3",
"eslint-plugin-node": "^11.1.0",
"markdownlint-cli": "^0.18.0",
"mocha": "^6.2.1",
"mocha-steps": "^1.3.0",
Expand All @@ -54,23 +57,26 @@
"shx": "^0.3.2",
"stream.pipeline-shim": "^1.1.0",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.6.3"
},
"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",
"pretest": "npm run lint",
"test": "npm run test:spec",
"test:spec": "npm run ts-mocha -- \"test/*.ts\"",
"test:coverage": "npm run clean:coverage && cross-env NYC=\"nyc --no-clean --reporter=lcov\" npm run test:spec && nyc report --reporter=text-summary --color",
"ts-mocha": "$NYC mocha --use_strict --throw-deprecation --require source-map-support/register --require ts-node/register --timeout 90000"
"test:spec": "$NYC mocha \"test/*.ts\"",
"test:coverage": "npm run clean:coverage && cross-env NYC=\"nyc --no-clean --reporter=lcov\" npm run test:spec && nyc report --reporter=text-summary --color"
}
}
15 changes: 8 additions & 7 deletions src/fs-gzip-blob-storage.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/// <reference types="node" />

import Pumpify from "pumpify"
import {Readable, Writable} from "stream"
import zlib from "zlib"

import Pumpify from "pumpify"

import {
FsBlobStorage,
FsBlobStorageCommitOptions,
FsBlobStorageOptions,
FsBlobStorageReadStreamOptions,
FsBlobStorageRemoveOptions,
FsBlobStorageWriteStreamOptions,
DEFAULT_EXT,
} from "fs-blob-storage"

export interface FsGzipBlobStorageOptions extends FsBlobStorageOptions {
Expand All @@ -29,21 +31,20 @@ export interface FsGzipBlobStorageWriteStreamOptions extends FsBlobStorageWriteS
export interface FsGzipBlobStorageCommitOptions extends FsBlobStorageCommitOptions {}
export interface FsGzipBlobStorageRemoveOptions extends FsBlobStorageRemoveOptions {}

export class FsGzipBlobStorage {
static readonly DEFAULT_EXT = FsBlobStorage.DEFAULT_EXT
static readonly DEFAULT_PART = FsBlobStorage.DEFAULT_PART
export {DEFAULT_EXT, DEFAULT_PART} from "fs-blob-storage"

static readonly DEFAULT_GZIP_EXT = ".gz"
export const DEFAULT_GZIP_EXT = ".gz"

export class FsGzipBlobStorage {
private storage: FsBlobStorage
private ext: string
private gzipExt: string
private gzipOptions: zlib.ZlibOptions

constructor(options: FsGzipBlobStorageOptions = {}) {
this.storage = new FsBlobStorage(options)
this.ext = options.ext !== undefined ? options.ext : FsGzipBlobStorage.DEFAULT_EXT
this.gzipExt = options.gzipExt !== undefined ? options.gzipExt : FsGzipBlobStorage.DEFAULT_GZIP_EXT
this.ext = options.ext !== undefined ? options.ext : DEFAULT_EXT
this.gzipExt = options.gzipExt !== undefined ? options.gzipExt : DEFAULT_GZIP_EXT
this.gzipOptions = options.gzipOptions || {}
}

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/fs-gzip-blob-storage-errors.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {expect} from "chai"

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

import {FsGzipBlobStorage} from "../src/fs-gzip-blob-storage"

import {mockFs} from "./lib/mock-fs"

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

const STORAGEDIR = "/tmp/storage"

Feature("Test FsGzipBlobStorage errors", () => {
Expand Down
Loading

0 comments on commit 1f01ed4

Please sign in to comment.