home
This commit is contained in:
parent
a71a3b5593
commit
cb52890889
16657 changed files with 1483086 additions and 1 deletions
51
home/ags/node_modules/eslint-plugin-es-x/lib/rules/no-numeric-separators.js
generated
vendored
Normal file
51
home/ags/node_modules/eslint-plugin-es-x/lib/rules/no-numeric-separators.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* @author Yosuke Ota
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
"use strict"
|
||||
|
||||
/**
|
||||
* Remove the numeric separators.
|
||||
* @param {string} raw The raw string of numeric literals
|
||||
* @returns {string} The string with the separators removed.
|
||||
*/
|
||||
function removeNumericSeparators(raw) {
|
||||
return raw.replace(/_/gu, "")
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
docs: {
|
||||
description: "disallow numeric separators.",
|
||||
category: "ES2021",
|
||||
recommended: false,
|
||||
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-numeric-separators.html",
|
||||
},
|
||||
fixable: "code",
|
||||
messages: {
|
||||
forbidden: "ES2021 numeric separators are forbidden.",
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
Literal(node) {
|
||||
if (
|
||||
(typeof node.value === "number" || node.bigint != null) &&
|
||||
node.raw.includes("_")
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "forbidden",
|
||||
fix: (fixer) =>
|
||||
fixer.replaceText(
|
||||
node,
|
||||
removeNumericSeparators(node.raw),
|
||||
),
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue