Skip to content

Commit

Permalink
Removes harmful tsconfig settings (#6)
Browse files Browse the repository at this point in the history
* Removes harmful tsconfig settings

Fixes eslint path issues
Updates fastify-plugin in the package-lock.json to fix export default issue
Uses `import flash = require('fastify-flash') to make it work with both esModuleInterop settings

* Adds more OS to CI/CD

* Fixes lint scripts on Windows

* Adds prettier EOL rule for Windows

* Adds eslint to test folder
  • Loading branch information
fox1t authored Sep 16, 2020
1 parent 377281e commit 50d0914
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 62 deletions.
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' }],
'@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 }}

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,
"emitDecoratorMetadata": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"removeComments": true,
"noUnusedLocals": true,
"lib": ["esnext"],
"lib": [
"esnext"
],
"rootDir": "./src"
},
"formatCodeOptions": {
"identSize": 2,
"tabSize": 2
},
"include": ["src"]
}
"include": [
"src"
]
}

0 comments on commit 50d0914

Please sign in to comment.