1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5 | }) : (function(o, m, k, k2) {
|
6 | if (k2 === undefined) k2 = k;
|
7 | o[k2] = m[k];
|
8 | }));
|
9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11 | }) : function(o, v) {
|
12 | o["default"] = v;
|
13 | });
|
14 | var __importStar = (this && this.__importStar) || function (mod) {
|
15 | if (mod && mod.__esModule) return mod;
|
16 | var result = {};
|
17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18 | __setModuleDefault(result, mod);
|
19 | return result;
|
20 | };
|
21 | var _a;
|
22 | Object.defineProperty(exports, "__esModule", { value: true });
|
23 | const util = __importStar(require("../util"));
|
24 | const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
25 | const baseRule = (0, getESLintCoreRule_1.maybeGetESLintCoreRule)('no-loss-of-precision');
|
26 | exports.default = util.createRule({
|
27 | name: 'no-loss-of-precision',
|
28 | meta: {
|
29 | type: 'problem',
|
30 | docs: {
|
31 | description: 'Disallow literal numbers that lose precision',
|
32 | recommended: 'error',
|
33 | extendsBaseRule: true,
|
34 | },
|
35 | hasSuggestions: baseRule === null || baseRule === void 0 ? void 0 : baseRule.meta.hasSuggestions,
|
36 | schema: [],
|
37 | messages: (_a = baseRule === null || baseRule === void 0 ? void 0 : baseRule.meta.messages) !== null && _a !== void 0 ? _a : { noLossOfPrecision: '' },
|
38 | },
|
39 | defaultOptions: [],
|
40 | create(context) {
|
41 | if (baseRule === null) {
|
42 | throw new Error('@typescript-eslint/no-loss-of-precision requires at least ESLint v7.1.0');
|
43 | }
|
44 |
|
45 | const rules = baseRule.create(context);
|
46 | function isSeparatedNumeric(node) {
|
47 | return typeof node.value === 'number' && node.raw.includes('_');
|
48 | }
|
49 | return {
|
50 | Literal(node) {
|
51 | rules.Literal(Object.assign(Object.assign({}, node), { raw: isSeparatedNumeric(node) ? node.raw.replace(/_/g, '') : node.raw }));
|
52 | },
|
53 | };
|
54 | },
|
55 | });
|
56 |
|
\ | No newline at end of file |