Skip to content

Commit

Permalink
fix: added linting
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-lindgren committed Sep 12, 2022
1 parent 3a0ffc1 commit f92b4ed
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 62 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
storybook-static/
dist/
scripts/
46 changes: 46 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
'env': {
'browser': true,
'es2021': true,
'node': true
},
'extends': [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
'overrides': [
],
'parser': '@typescript-eslint/parser',
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module'
},
'plugins': [
'@typescript-eslint',
"prettier",
"prefer-arrow",
"functional",
],
'rules': {
"no-var": "error",
"prettier/prettier": ["warn"],
"prefer-arrow/prefer-arrow-functions": "error",
"functional/immutable-data": "error",
"functional/no-let": "error",
"functional/no-class": "error",
"functional/no-mixed-type": "error",
"functional/no-this-expression": "error",
"functional/no-loop-statement": "error",
"functional/no-promise-reject": "error",
'no-unused-vars': [
'warn',
{
args: "none",
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
]
}
}
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .yarnrc
save-exact true
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dist/"
],
"scripts": {
"lint": "eslint .",
"build": "rollup -c",
"start": "rollup -c -w",
"test": "jest"
Expand All @@ -43,11 +44,19 @@
"@types/jsonwebtoken": "^8.5.8",
"@types/react": "react@^17.0.2 || ^18.0.0-0",
"@types/react-dom": "react@^17.0.2 || ^18.0.0-0",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"dotenv": "^16.0.0",
"eslint": "8.22.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-functional": "^4.3.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^27.5.1",
"jest-express": "^1.12.0",
"node-mocks-http": "^1.11.0",
"oauth2-mock-server": "^4.3.1",
"prettier": "^2.7.1",
"require": "^2.4.20",
"rollup": "^2.78.0",
"rollup-plugin-dts": "4.2.1",
Expand All @@ -57,7 +66,8 @@
"rollup-plugin-typescript2": "^0.31.1",
"rollup-plugin-visualizer": "^5.6.0",
"ts-jest": "^27.1.4",
"typescript": "^4.7.4"
"tsutils": "^3.21.0",
"typescript": "^4.8.3"
},
"peerDependencies": {}
}
8 changes: 8 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
bracketSpacing: true,
printWidth: 80,
semi: false,
singleQuote: true,
trailingComma: 'all',
singleAttributePerLine: true,
}
3 changes: 1 addition & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import commonjs from '@rollup/plugin-commonjs';
import {visualizer} from 'rollup-plugin-visualizer'
import summary from "rollup-plugin-summary";
import json from '@rollup/plugin-json';

const packageJson = require('./package.json');
import packageJson from './package.json'

export default ({
input: `./src/index.ts`,
Expand Down
1 change: 0 additions & 1 deletion src/storyblok-auth-api/grant/authorized-handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import http from "http";
// @ts-ignore
import makeSessionParser from "grant/lib/session";
import {appendQueryParams} from "@src/utils/query-params/append-query-params";
import {AppSession, AppSessionQueryParams} from "@src/session/app-session";
Expand Down
10 changes: 5 additions & 5 deletions src/storyblok-auth-api/storyblok-issuer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Issuer} from "openid-client";

export const oauthEndpoint = 'https://app.storyblok.com/oauth'
const oauthEndpoint = 'https://app.storyblok.com/oauth'
export const profile_url = `${oauthEndpoint}/user_info`

export const storyblokIssuer = new Issuer({
issuer: 'storyblok',
authorization_endpoint: require('grant/config/oauth.json').storyblok.authorize_url,
token_endpoint: require('grant/config/oauth.json').storyblok.access_url,
userinfo_endpoint: profile_url,
issuer: 'storyblok',
authorization_endpoint: 'https://app.storyblok.com/oauth/authorize',
token_endpoint: "https://app.storyblok.com/oauth/token",
userinfo_endpoint: profile_url,
})
25 changes: 7 additions & 18 deletions src/utils/cookie/get-cookie.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import http from "http";


/**
* Cache for generated name regular expressions.
*/

const REGEXP_CACHE = Object.create(null)

/**
* RegExp to match all characters to escape in a RegExp.
*/

const REGEXP_ESCAPE_CHARS_REGEXP = /[\^$\\.*+?()[\]{}|]/g

function getPattern (name: string) {
if (!REGEXP_CACHE[name]) {
REGEXP_CACHE[name] = new RegExp(
'(?:^|;) *' +
name.replace(REGEXP_ESCAPE_CHARS_REGEXP, '\\$&') +
'=([^;]*)'
)
}

return REGEXP_CACHE[name]
}
const getPattern = (name: string) => (
new RegExp(
'(?:^|;) *' +
name.replace(REGEXP_ESCAPE_CHARS_REGEXP, '\\$&') +
'=([^;]*)'
)
)

export const getCookie = (request: http.IncomingMessage, name: string): string | undefined => {
const header = request.headers["cookie"]
Expand Down
Loading

0 comments on commit f92b4ed

Please sign in to comment.