Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
40
Frontend-Learner/node_modules/eslint-plugin-unicorn/rules/no-this-assignment.js
generated
vendored
Normal file
40
Frontend-Learner/node_modules/eslint-plugin-unicorn/rules/no-this-assignment.js
generated
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const MESSAGE_ID = 'no-this-assignment';
|
||||
const messages = {
|
||||
[MESSAGE_ID]: 'Do not assign `this` to `{{name}}`.',
|
||||
};
|
||||
|
||||
function getProblem(variableNode, valueNode) {
|
||||
if (
|
||||
variableNode.type !== 'Identifier'
|
||||
|| valueNode?.type !== 'ThisExpression'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
node: valueNode.parent,
|
||||
data: {name: variableNode.name},
|
||||
messageId: MESSAGE_ID,
|
||||
};
|
||||
}
|
||||
|
||||
/** @param {import('eslint').Rule.RuleContext} context */
|
||||
const create = context => {
|
||||
context.on('VariableDeclarator', node => getProblem(node.id, node.init));
|
||||
context.on('AssignmentExpression', node => getProblem(node.left, node.right));
|
||||
};
|
||||
|
||||
/** @type {import('eslint').Rule.RuleModule} */
|
||||
const config = {
|
||||
create,
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'Disallow assigning `this` to a variable.',
|
||||
recommended: 'unopinionated',
|
||||
},
|
||||
messages,
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
Loading…
Add table
Add a link
Reference in a new issue