-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
--report-unused-inline-configs
(#19201)
* feat: add --report-unused-inline-configs / linterOptions.reportUnusedInlineConfigs * fix: unused severity normalization refactor * Update lib/linter/linter.js * Review feedback: reverting when in eslintrc mode * Apply suggestions from code review Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Review feedback: removing boolean support * Review feedback: explain 'unused' * fix: getDirectiveComments call * Update unit tests to put logic within FlatConfigArray * Finish updating tests: cli.js * fix: any array size is a difference * fix: any object key mismatch is a difference too * git checkout main -- docs/src/use/configure/migration-guide.md * fix: remove migration notice from inline configs note in eslintrc-incompat.js * git checkout main -- messages/eslintrc-incompat.js * Update docs/src/integrate/nodejs-api.md Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Apply suggestions from code review Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * rules.md touchups * Handle nullish values in containsDifferentProperty * Revert lib/shared/severity.js whitespace change * Apply suggestions from code review Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Fix option-utils, and collectively update tests * Report already-disabled rules too * Ah, on second thought, one more unit test... * Update lib/linter/linter.js Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Updated tests too * Apply suggestions from code review Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update lib/linter/linter.js Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> --------- Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
- Loading branch information
1 parent
e39d3f2
commit 1637b8e
Showing
14 changed files
with
593 additions
and
12 deletions.
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
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 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 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 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 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 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 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,56 @@ | ||
/** | ||
* @fileoverview Utilities to operate on option objects. | ||
* @author Josh Goldberg | ||
*/ | ||
|
||
"use strict"; | ||
|
||
/** | ||
* Determines whether any of input's properties are different | ||
* from values that already exist in original. | ||
* @template T | ||
* @param {Partial<T>} input New value. | ||
* @param {T} original Original value. | ||
* @returns {boolean} Whether input includes an explicit difference. | ||
*/ | ||
function containsDifferentProperty(input, original) { | ||
if (input === original) { | ||
return false; | ||
} | ||
|
||
if ( | ||
typeof input !== typeof original || | ||
Array.isArray(input) !== Array.isArray(original) | ||
) { | ||
return true; | ||
} | ||
|
||
if (Array.isArray(input)) { | ||
return ( | ||
input.length !== original.length || | ||
input.some((value, i) => | ||
containsDifferentProperty(value, original[i])) | ||
); | ||
} | ||
|
||
if (typeof input === "object") { | ||
if (input === null || original === null) { | ||
return true; | ||
} | ||
|
||
const inputKeys = Object.keys(input); | ||
const originalKeys = Object.keys(original); | ||
|
||
return inputKeys.length !== originalKeys.length || inputKeys.some( | ||
inputKey => | ||
!Object.hasOwn(original, inputKey) || | ||
containsDifferentProperty(input[inputKey], original[inputKey]) | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
module.exports = { | ||
containsDifferentProperty | ||
}; |
Oops, something went wrong.