Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix: clone config data before validation (fixes #12592) * Chore: added test and cloning before validation * Chore: test fix * Chore: rules tests fixes * Update: cloning config using json parse and stringify * Update: changed test description * Chore: removed unnecessary tests * Update: changed clone logic * Update: using lodash.cloneDeepWith for cloning * Update: handling circular ref cases * Update: using JSON method for cloning logic * Update: moved clone logic to normalieObjectConfigData * Chore: added comments for cloning reason
- Loading branch information
1 parent
aed46f6
commit 7fb45cf
Showing
7 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/fixtures/config-file/cloned-config/circularRefEslintConfig.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
let errorConfig = ["error", {}]; | ||
|
||
class CircularRef { | ||
constructor() { | ||
this.self = this; | ||
} | ||
} | ||
|
||
module.exports = { | ||
settings: { | ||
sharedData: new CircularRef() | ||
}, | ||
|
||
rules: { camelcase: errorConfig, "default-case": errorConfig } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let errorConfig = ["error", {}]; | ||
module.exports = { | ||
rules: { camelcase: errorConfig, "default-case": errorConfig } | ||
}; |
13 changes: 13 additions & 0 deletions
13
tests/fixtures/config-file/cloned-config/eslintConfigFail.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let errorConfig = ["error", {}]; | ||
module.exports = { | ||
rules: { | ||
camelcase: errorConfig, | ||
"default-case": errorConfig , | ||
"camelcase" : [ | ||
'error', | ||
{ | ||
"ignoreDestructuring": new Date().getUTCFullYear // returns a function | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var someValue = "bar"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*eslint default-case: ["error", {}]*/ | ||
/*eslint camelcase: ["error", {}]*/ | ||
var someValue = "bar"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This breaks configurations that use
Infinity
in their options