source: imaps-frontend/node_modules/eslint/lib/rules/no-multi-assign.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[d565449]1/**
2 * @fileoverview Rule to check use of chained assignment expressions
3 * @author Stewart Rand
4 */
5
6"use strict";
7
8
9//------------------------------------------------------------------------------
10// Rule Definition
11//------------------------------------------------------------------------------
12
13/** @type {import('../shared/types').Rule} */
14module.exports = {
15 meta: {
16 type: "suggestion",
17
18 docs: {
19 description: "Disallow use of chained assignment expressions",
20 recommended: false,
21 url: "https://eslint.org/docs/latest/rules/no-multi-assign"
22 },
23
24 schema: [{
25 type: "object",
26 properties: {
27 ignoreNonDeclaration: {
28 type: "boolean",
29 default: false
30 }
31 },
32 additionalProperties: false
33 }],
34
35 messages: {
36 unexpectedChain: "Unexpected chained assignment."
37 }
38 },
39
40 create(context) {
41
42 //--------------------------------------------------------------------------
43 // Public
44 //--------------------------------------------------------------------------
45 const options = context.options[0] || {
46 ignoreNonDeclaration: false
47 };
48 const selectors = [
49 "VariableDeclarator > AssignmentExpression.init",
50 "PropertyDefinition > AssignmentExpression.value"
51 ];
52
53 if (!options.ignoreNonDeclaration) {
54 selectors.push("AssignmentExpression > AssignmentExpression.right");
55 }
56
57 return {
58 [selectors](node) {
59 context.report({
60 node,
61 messageId: "unexpectedChain"
62 });
63 }
64 };
65
66 }
67};
Note: See TracBrowser for help on using the repository browser.