Skip to content

Commit

Permalink
Merge b26bbc7 into 4ced566
Browse files Browse the repository at this point in the history
  • Loading branch information
necojackarc committed Aug 30, 2020
2 parents 4ced566 + b26bbc7 commit e80d770
Show file tree
Hide file tree
Showing 11 changed files with 1,190 additions and 1,352 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

57 changes: 47 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
module.exports = {
extends: 'eslint:recommended',
env: {
browser: true,
es6: true,
mocha: true,
node: true,
mocha: true,
},
root: true,
extends: 'eslint:recommended',
rules: {
'comma-dangle': ['error', {
'array-bracket-spacing': [ 'error', 'always' ],
'array-callback-return': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'block-spacing': 'error',
'brace-style': [ 'error', '1tbs', { allowSingleLine: false } ],
'comma-dangle': [ 'error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
}],
} ],
'comma-spacing': 'error',
'comma-style': 'error',
'curly': 'error',
'dot-notation': 'error',
'eol-last': 'error',
'eqeqeq': [ 'error', 'always' ],
'func-call-spacing': 'error',
'indent': [ 'error', 2, { SwitchCase: 1 } ],
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': 'error',
'no-array-constructor': 'error',
'no-else-return': 'error',
'no-eval': 'error',
'no-multi-spaces': 'error',
'no-multiple-empty-lines': [ 'error', { max: 2, maxEOF: 1, maxBOF: 1 } ],
'no-new-object': 'error',
'no-param-reassign': 'error',
'no-plusplus': 'error',
'no-restricted-globals': [ 'error', 'isNaN', 'isFinite' ],
'no-spaced-func': 'error',
'no-trailing-spaces': 'error',
'no-underscore-dangle': ['error', { 'allowAfterThis': true }],
'no-underscore-dangle': [ 'error', { allowAfterThis: true } ],
'no-var': 'error',
'object-curly-spacing': [ 'error', 'always' ],
'operator-linebreak': [ 'error', 'before' ],
'prefer-const': 'error',
'quote-props': ['error', 'consistent-as-needed'],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
}
'prefer-rest-params': 'error',
'quote-props': [ 'error', 'consistent-as-needed' ],
'quotes': [ 'error', 'single', {
avoidEscape: true,
} ],
'radix': 'error',
'rest-spread-spacing': 'error',
'semi': [ 'error', 'always' ],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'spaced-comment': [ 'error', 'always', { block: { balanced: true } } ],
},
};
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: ['**']

jobs:
test:
name: Run linter and tests
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: yarn install

- name: Run linter and tests
run: |
yarn lint
yarn test
yarn coverage
- name: Send test coverage report to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Extensible Custom Error

[![npm version](https://badge.fury.io/js/extensible-custom-error.svg)](https://badge.fury.io/js/extensible-custom-error)
[![Build Status](https://travis-ci.com/necojackarc/extensible-custom-error.svg?branch=master)](https://travis-ci.com/necojackarc/extensible-custom-error)
![CI](https://github.com/necojackarc/extensible-custom-error/workflows/CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/necojackarc/extensible-custom-error/badge.svg?branch=master)](https://coveralls.io/github/necojackarc/extensible-custom-error?branch=master)
[![npm version](https://badge.fury.io/js/extensible-custom-error.svg)](https://badge.fury.io/js/extensible-custom-error)

JavaScript extensible custom error that can take a message and/or an Error object

Expand Down
Empty file added coverage/.keep
Empty file.
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"types": "types/index.d.ts",
"scripts": {
"lint": "eslint src test",
"test": "nyc mocha test",
"coverage": "nyc report --reporter=text-lcov | coveralls"
"test": "nyc --all mocha test",
"coverage": "nyc report --reporter=text-lcov > coverage/lcov.info"
},
"repository": {
"type": "git",
Expand All @@ -24,11 +24,15 @@
"homepage": "https://github.com/necojackarc/extensible-custom-error#readme",
"devDependencies": {
"chai": "^4.2.0",
"coveralls": "^3.0.4",
"eslint": "^6.0.1",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"typescript": "^3.5.2",
"eslint": "^7.7.0",
"mocha": "^8.1.3",
"nyc": "^15.1.0",
"typescript": "^4.0.2",
"typings-tester": "^0.3.2"
},
"nyc": {
"include": [
"src"
]
}
}
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class ExtensibleCustomError extends Error {
newEntries.push(entry);
});

return [...newEntries, ...baseEntries].join('\n');
return [ ...newEntries, ...baseEntries ].join('\n');
};

const stackTraceSoFar = errorToWrap ? errorToWrap.stack : undefined;

if (Error.hasOwnProperty('captureStackTrace')) {
if (Object.prototype.hasOwnProperty.call(Error, 'captureStackTrace')) {
Error.captureStackTrace(this, this.constructor);
this.stack = mergeStackTrace(this.stack, stackTraceSoFar);
return;
Expand All @@ -54,8 +54,8 @@ class ExtensibleCustomError extends Error {
// This class is supposed to be extended, so the first two lines from
// the second line are about error object constructors.
const stackTraceEntries = new Error(message).stack.split('\n');
const stackTraceWithoutConstructors =
[stackTraceEntries[0], ...stackTraceEntries.slice(3)].join('\n');
const stackTraceWithoutConstructors
= [ stackTraceEntries[0], ...stackTraceEntries.slice(3) ].join('\n');

this.stack = mergeStackTrace(stackTraceWithoutConstructors, stackTraceSoFar);
}
Expand Down
6 changes: 3 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe('ExtensibleCustomError', function() {
const className = 'MyError';
const captureStackTrace = Error.captureStackTrace;

[true, false].forEach((isCaptureStackTraceAvailable) => {
const availability =
isCaptureStackTraceAvailable ? 'available' : 'unavailable';
[ true, false ].forEach((isCaptureStackTraceAvailable) => {
const availability
= isCaptureStackTraceAvailable ? 'available' : 'unavailable';

context(`when captureStackTrace is ${availability}`, function() {
before(function() {
Expand Down
3 changes: 0 additions & 3 deletions test/typescript.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
'use strict';

const path = require('path');
const { expect } = require('chai');
const { checkDirectory } = require('typings-tester');

const ExtensibleCustomError = require('../src');

describe('TypeScript definitions', function() {
it('should compile against index.d.ts', function() {
checkDirectory(path.join(__dirname, 'typescript'));
Expand Down
Loading

0 comments on commit e80d770

Please sign in to comment.