home
This commit is contained in:
parent
a71a3b5593
commit
cb52890889
16657 changed files with 1483086 additions and 1 deletions
62
home/ags/node_modules/eslint-plugin-es-x/lib/rules/no-trailing-function-commas.js
generated
vendored
Normal file
62
home/ags/node_modules/eslint-plugin-es-x/lib/rules/no-trailing-function-commas.js
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
"use strict"
|
||||
|
||||
const { getSourceCode } = require("eslint-compat-utils")
|
||||
const { isCommaToken } = require("../utils")
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
docs: {
|
||||
description:
|
||||
"disallow trailing commas in parameter/argument lists.",
|
||||
category: "ES2017",
|
||||
recommended: false,
|
||||
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-trailing-function-commas.html",
|
||||
},
|
||||
fixable: "code",
|
||||
messages: {
|
||||
forbidden:
|
||||
"ES2017 trailing commas in parameter/argument lists are forbidden.",
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = getSourceCode(context)
|
||||
return {
|
||||
":function"(node) {
|
||||
const length = node.params.length
|
||||
if (length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const lastParam = node.params[length - 1]
|
||||
const token = sourceCode.getTokenAfter(lastParam)
|
||||
if (isCommaToken(token)) {
|
||||
context.report({
|
||||
loc: token.loc,
|
||||
messageId: "forbidden",
|
||||
fix(fixer) {
|
||||
return fixer.remove(token)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
"CallExpression, NewExpression"(node) {
|
||||
const token = sourceCode.getLastToken(node, 1)
|
||||
if (node.arguments.length >= 1 && isCommaToken(token)) {
|
||||
context.report({
|
||||
loc: token.loc,
|
||||
messageId: "forbidden",
|
||||
fix(fixer) {
|
||||
return fixer.remove(token)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue