Skip to content

Commit

Permalink
fix: deep copy standardRules config
Browse files Browse the repository at this point in the history
This fixes #303 invalid configuration for dot-notation
  • Loading branch information
Patrick-Remy authored and mightyiam committed May 25, 2020
1 parent 6fdc4ca commit db3467d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const equivalents = [
'space-before-function-paren'
] as const

function clone<T extends object | string | number | boolean | null> (value: T): T {
return JSON.parse(JSON.stringify(value))
}

function fromEntries<T> (iterable: Array<[string, T]>): { [key: string]: T } {
return [...iterable].reduce<{ [key: string]: T }>((obj, [key, val]) => {
obj[key] = val
Expand All @@ -44,7 +48,7 @@ export = {
'no-use-before-define': 'off',

// @typescript-eslint versions of Standard.js rules:
...fromEntries(equivalents.map((name) => [`@typescript-eslint/${name}`, standardRules[name]])),
...fromEntries(equivalents.map((name) => [`@typescript-eslint/${name}`, clone(standardRules[name])])),
'@typescript-eslint/no-use-before-define': ['error', {
functions: false,
classes: false,
Expand Down

0 comments on commit db3467d

Please sign in to comment.