Skip to content

Commit d33dfd3

Browse files
SwetaTanwarkirkwaiblinger
authored andcommitted
fix: fix spurious failure in neostandard integration test
1 parent 676f4ac commit d33dfd3

File tree

3 files changed

+4
-31
lines changed

3 files changed

+4
-31
lines changed

.github/workflows/types-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- name: Install Packages (neostandard)
6868
working-directory: neostandard
6969
run: |
70-
npm install --no-package-lock ../eslint
70+
npm ci && npm install eslint@file:../eslint
7171
7272
- name: Run TSC
7373
working-directory: neostandard

lib/rules/no-loss-of-precision.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,9 @@ module.exports = {
189189
* @returns {boolean} true if they do not match
190190
*/
191191
function baseTenLosesPrecision(node) {
192-
const rawNumber = getRaw(node);
193-
194-
/*
195-
* If trailing zeros equal the exponent, this is a valid representation
196-
* like "9.00e2" where 00 = 2 (meaning 9.00 * 10^2 = 900)
197-
* https://github.com/eslint/eslint/issues/19957
198-
*/
199-
if (rawNumber.includes(".") && rawNumber.includes("e")) {
200-
const parts = rawNumber.split("e");
201-
const coefficient = parts[0];
202-
const exponent = parseInt(parts[1], 10);
203-
204-
// Count trailing zeros after decimal
205-
const decimalParts = coefficient.split(".");
206-
if (decimalParts.length === 2) {
207-
const decimalPart = decimalParts[1];
208-
const trailingZeros = decimalPart.match(/0*$/u)[0].length;
209-
210-
if (trailingZeros === exponent) {
211-
return false;
212-
}
213-
}
214-
}
215-
216-
const normalizedRawNumber =
217-
convertNumberToScientificNotation(rawNumber);
192+
const normalizedRawNumber = convertNumberToScientificNotation(
193+
getRaw(node),
194+
);
218195
const requestedPrecision = normalizedRawNumber
219196
.split("e")[0]
220197
.replace(".", "").length;

tests/lib/rules/no-loss-of-precision.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ ruleTester.run("no-loss-of-precision", rule, {
4848
"var x = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000",
4949
"var x = -0",
5050
"var x = 123.0000000000000000000000",
51-
// https://github.com/eslint/eslint/issues/19957
52-
"var x = 9.00e2",
53-
"var x = 9.000e3",
54-
"var x = 9.0000000000e10",
5551
"var x = 019.5",
5652
"var x = 0195",
5753
"var x = 0e5",

0 commit comments

Comments
 (0)