Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes harmful tsconfig settings #6

Merged
merged 5 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build
dist
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.json',
project: './tsconfig.eslint.json',
},
settings: {
react: {
Expand All @@ -17,6 +17,7 @@ module.exports = {
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
rules: {
'prettier/prettier': ['error', { endOfLine: 'auto' }],
fox1t marked this conversation as resolved.
Show resolved Hide resolved
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
fox1t marked this conversation as resolved.
Show resolved Hide resolved

strategy:
matrix:
node-version: [12.x, 14.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v1
Expand Down
73 changes: 32 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "rimraf ./dist && mkdir dist && tsc --outDir dist && git rev-parse HEAD > BUILD_SHA",
"lint": "eslint '*/**/*.{js,ts,tsx}'",
"lint:fix": "prettier --loglevel warn --write \"src/**/*.{ts,tsx}\" && eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"lint": "eslint \"*/**/*.{js,ts,tsx}\"",
"lint:fix": "prettier --loglevel warn --write \"src/**/*.{ts,tsx}\" && eslint \"*/**/*.{js,ts,tsx}\" --quiet --fix",
"prepublishOnly": "npm run build",
"test": "npm run build && npm run test:unit && npm run lint",
"test:unit": "jest"
Expand Down Expand Up @@ -72,4 +72,4 @@
"files": [
"dist"
]
}
}
2 changes: 1 addition & 1 deletion src/AuthenticationRoute.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference types="fastify-secure-session" />
import http from 'http'
import * as http from 'http'
import AuthenticationError from './errors'
import Authenticator from './Authenticator'
import { Strategy } from './strategies'
Expand Down
2 changes: 1 addition & 1 deletion src/CreateInitializePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fp from 'fastify-plugin'
import { logIn, logOut, isAuthenticated, isUnauthenticated } from './decorators'
import Authenticator from './Authenticator'
import flash from 'fastify-flash'
import flash = require('fastify-flash')

export function CreateInitializePlugin(passport: Authenticator, options: { userProperty?: string } = {}) {
return fp(async (fastify) => {
Expand Down
4 changes: 2 additions & 2 deletions test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs'
import * as fs from 'fs'
import fastify, { FastifyInstance } from 'fastify'
import fastifySecureSession from 'fastify-secure-session'
import Authenticator from '../src/Authenticator'
import { Strategy } from '../src/strategies'
import { InjectOptions, Response as LightMyRequestResponse } from 'light-my-request'
import parseCookies from 'set-cookie-parser'
import * as parseCookies from 'set-cookie-parser'

const SecretKey = fs.readFileSync(__dirname + '/secure.key')

Expand Down
7 changes: 7 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": [
"src",
"test"
]
}
18 changes: 7 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@
"module": "commonjs",
"pretty": true,
"noEmitOnError": true,
"experimentalDecorators": true,
"sourceMap": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no source maps? I think they're still relevant on the server for debugging with the devtools, or for tooling like Sentry to pull in to show you the actual source that generated an error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do source maps even work if no src folder is shipped? Regardelss, personally, I never ship sourcemaps since there is no need for the final user to debug library code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source maps get written alongside the typescript compiler's output so yes they should still be included in the npm package. And I kind of feel like there isn't a downside to shipping them -- what happens if someone suspects there is a bug in this library, I feel like they would debug it wouldn't they? Especially if it's a pre-release library that has a higher likelihood of bugs, wouldn't we want to provide the best debugging experience possible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience having a user that is going to debug a lib in node_modules is really rare. More often than not when something brakes they just open an issue, without even providing a repro repo.

Usually, libraries don't ship maps because they are tested and hopefully maps can't provide any useful info. Maps, of course, are mainly used for application code.

If it is important for you, we can re-add them, though.

"emitDecoratorMetadata": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
fox1t marked this conversation as resolved.
Show resolved Hide resolved
"removeComments": true,
"noUnusedLocals": true,
"lib": ["esnext"],
"lib": [
"esnext"
],
"rootDir": "./src"
},
"formatCodeOptions": {
"identSize": 2,
"tabSize": 2
},
"include": ["src"]
}
"include": [
"src"
]
}