Skip to content

Commit

Permalink
Enable ESLint rule and suppress errors for data flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kox committed Dec 14, 2024
1 parent 141033c commit 7296876
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default [
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/unbound-method': 'off',
'jest/expect-expect': [
Expand Down
4 changes: 4 additions & 0 deletions packages/fast-stable-stringify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ function stringify(val: unknown, isArrayProp: boolean) {
str = '[';
max = (val as unknown[]).length - 1;
for (i = 0; i < max; i++) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
str += stringify((val as unknown[])[i], true) + ',';
}
if (max > -1) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
str += stringify((val as unknown[])[i], true);
}
return str + ']';
Expand All @@ -48,6 +50,7 @@ function stringify(val: unknown, isArrayProp: boolean) {
if (str) {
str += ',';
}
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
str += JSON.stringify(key) + ':' + propVal;
}
i++;
Expand Down Expand Up @@ -78,6 +81,7 @@ export default function (val: unknown): string;
export default function (val: unknown): string | undefined {
const returnVal = stringify(val, false);
if (returnVal !== undefined) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return '' + returnVal;
}
}

0 comments on commit 7296876

Please sign in to comment.