Skip to content

Commit

Permalink
Merge a8e0abb into 5b0ff78
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Oct 4, 2020
2 parents 5b0ff78 + a8e0abb commit d4c7b63
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 87 deletions.
2 changes: 0 additions & 2 deletions .eslintignore
@@ -1,3 +1 @@
coverage/**
lib/**
out/**
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 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,7 +2,9 @@

## v3.0.0 YYYY-mm-dd

- `DEFAULT_EXT` and `DEFAULT_PART` are constant strings.
- Correct typings for updates @types/node.
- Converted from tslint to eslint.

## v2.1.4 2019-10-08

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -44,7 +44,7 @@ _Typescript:_
```ts
import FsBlobStorage from "fs-blob-storage"
// or
import {FsBlobStorage} from "fs-blob-storage"
import {FsBlobStorage, DEFAULT_EXT, DEFAULT_PART} from "fs-blob-storage"
```

### DEFAULT_EXT
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
4 changes: 2 additions & 2 deletions examples/test-fs-blob-storage-read-ts.ts
Expand Up @@ -2,13 +2,13 @@

/// <reference lib="es2017" />

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

import "stream.pipeline-shim/auto"

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

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

const pipelinePromise = util.promisify(stream.pipeline)

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

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

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

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

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

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
4 changes: 2 additions & 2 deletions examples/test-fs-blob-storage-write-ts.ts
Expand Up @@ -2,13 +2,13 @@

/// <reference lib="es2017" />

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

import "stream.pipeline-shim/auto"

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

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

const pipelinePromise = util.promisify(stream.pipeline)

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

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

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

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

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

const pipelinePromise = util.promisify(stream.pipeline)

const SPOOLDIR = process.env.SPOOLDIR || "."
Expand Down
23 changes: 15 additions & 8 deletions package.json
Expand Up @@ -32,16 +32,19 @@
"@types/dirty-chai": "^2.0.2",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.62",
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/eslint-plugin-tslint": "^4.3.0",
"@typescript-eslint/parser": "^4.3.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",
"make-dir": "^3.0.0",
"markdownlint-cli": "^0.18.0",
"mocha": "^6.2.1",
Expand All @@ -53,16 +56,20 @@
"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",
Expand Down
13 changes: 7 additions & 6 deletions src/fs-blob-storage.ts
@@ -1,10 +1,11 @@
/// <reference types="node" />

import fs from "fs"
import mkdir from "fs.mkdir-shim"
import path from "path"
import util from "util"

import mkdir from "fs.mkdir-shim"

export interface FsBlobStorageOptions {
ext?: string
part?: string
Expand Down Expand Up @@ -42,10 +43,10 @@ interface FsPromises {
unlink: typeof fs.unlink.__promisify__
}

export class FsBlobStorage {
static readonly DEFAULT_EXT = ""
static readonly DEFAULT_PART = ".part"
export const DEFAULT_EXT = ""
export const DEFAULT_PART = ".part"

export class FsBlobStorage {
protected ext: string
protected part: string
protected writeFlags: string
Expand All @@ -55,8 +56,8 @@ export class FsBlobStorage {
protected fsPromises: FsPromises

constructor(options: FsBlobStorageOptions = {}) {
this.ext = options.ext !== undefined ? options.ext : FsBlobStorage.DEFAULT_EXT
this.part = options.part !== undefined ? options.part : FsBlobStorage.DEFAULT_PART
this.ext = options.ext !== undefined ? options.ext : DEFAULT_EXT
this.part = options.part !== undefined ? options.part : DEFAULT_PART
this.writeFlags = options.exclusive ? "wx" : "w"
this.fs = options.fs || fs
this.path = options.path || "."
Expand Down
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/fs-blob-storage-errors.ts
@@ -1,11 +1,11 @@
import {expect} from "chai"

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

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

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

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

const STORAGEDIR = "/tmp/storage"

Feature("Test FsBlobStorage errors", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/fs-blob-storage-exclusive-errors.ts
@@ -1,11 +1,11 @@
import {expect} from "chai"

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

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

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

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

const STORAGEDIR = "/tmp/storage"

Feature("Test FsBlobStorage errors for exclusive option", () => {
Expand Down

0 comments on commit d4c7b63

Please sign in to comment.