Skip to content

Commit

Permalink
Merge pull request #17 from hckrnews/feature/type-async-function
Browse files Browse the repository at this point in the history
Feature/type async function
  • Loading branch information
w3nl committed Dec 14, 2021
2 parents d120814 + 3f2a1d9 commit e1ddeba
Show file tree
Hide file tree
Showing 8 changed files with 2,511 additions and 2,433 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SonarCloud

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint, and test
run: |
npm ci
npm run lint:report
npm test
env:
CI: true
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.13.1
11 changes: 11 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ module.exports = {

collectCoverage: true,
collectCoverageFrom: ['src/**/*.js'],

reporters: [
'default',
[ 'jest-junit', {
outputDirectory: 'test-reports',
outputName: 'jest-junit.xml',
} ]
],

testResultsProcessor: 'jest-sonar-reporter',
coveragePathIgnorePatterns: ['__fixtures__']
};
4,864 changes: 2,440 additions & 2,424 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "@hckrnews/error",
"description": "Extended Errors",
"version": "0.3.3",
"version": "0.3.4",
"author": {
"name": "Pieter Wigboldus",
"url": "https://hckr.news/"
},
"license": "MIT",
"scripts": {
"lint": "eslint src/*.js --config .eslintrc",
"lint:report": "eslint src/*.js --config .eslintrc -f json -o report.json",
"lint:fix": "eslint src/*.js --config .eslintrc --fix",
"test": "jest",
"test:watch": "jest src --watch",
Expand All @@ -35,21 +36,23 @@
"@babel/eslint-parser": "^7.14.7",
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
"@babel/preset-env": "^7.9.5",
"@jest/globals": "^27.0.6",
"@hckrnews/eslint-config": "^2.0.1",
"@jest/globals": "^27.0.6",
"babel-jest": "^27.0.5",
"codecov": "^3.6.5",
"coveralls": "^3.0.13",
"eslint": "^7.24.0",
"eslint-config-airbnb": "^18.2.0",
"eslint": "^8.4.1",
"eslint-config-airbnb": "^19.0.2",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.0.5",
"jest-junit": "^13.0.0",
"jest-sonar-reporter": "^2.0.0",
"jscpd": "^3.2.1",
"prettier": "^2.2.1"
"prettier": "^2.5.1"
},
"repository": {
"type": "git",
Expand Down
15 changes: 15 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sonar.organization=hckrnews
sonar.projectKey=hckrnews_error

# relative paths to source directories. More details and properties are described
# in https://sonarcloud.io/documentation/project-administration/narrowing-the-focus/
sonar.sources=.
sonar.exclusions=**/__**__/*.js
sonar.language=js
sonar.tests=./src/__tests__

sonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar.testExecutionReportPaths=./test-report.xml
sonar.eslint.reportPaths=./report.json

sonar.sourceEncoding=UTF-8
5 changes: 3 additions & 2 deletions src/__tests__/no-content-error.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { NoContentError } from '../index.js';

describe('No Content Error test', () => {
it('It should create a no content error', () => {
const fetch = async () => ({})
const error = new NoContentError({
value: 'test',
type: String,
type: fetch,
message: 'Example text',
});

Expand All @@ -16,7 +17,7 @@ describe('No Content Error test', () => {
expect(error.message).toEqual('Example text');
expect(error.value).toEqual('test');
expect(error.status).toEqual(204);
expect(error.type).toEqual(String);
expect(error.type).toEqual(fetch);
expect(error.date.constructor).toEqual(Date);
expect(error.stack.includes('NoContentError: Example text')).toEqual(
true
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export default {
message: String,
'value?': 'mixed',
status: Number,
'type?': Function,
'type?': "function|async",
date: Date,
};

0 comments on commit e1ddeba

Please sign in to comment.