Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint/lib/rules/no-new.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 lines (34 sloc)
1.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Rule to flag statements with function invocation preceded by | |
* "new" and not part of assignment | |
* @author Ilya Volodin | |
*/ | |
"use strict"; | |
//------------------------------------------------------------------------------ | |
// Rule Definition | |
//------------------------------------------------------------------------------ | |
module.exports = { | |
meta: { | |
type: "suggestion", | |
docs: { | |
description: "disallow `new` operators outside of assignments or comparisons", | |
category: "Best Practices", | |
recommended: false, | |
url: "https://eslint.org/docs/rules/no-new" | |
}, | |
schema: [], | |
messages: { | |
noNewStatement: "Do not use 'new' for side effects." | |
} | |
}, | |
create(context) { | |
return { | |
"ExpressionStatement > NewExpression"(node) { | |
context.report({ | |
node: node.parent, | |
messageId: "noNewStatement" | |
}); | |
} | |
}; | |
} | |
}; |