massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / rules / no-multi-assign.js
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 module.exports = {
14     meta: {
15         type: "suggestion",
16
17         docs: {
18             description: "disallow use of chained assignment expressions",
19             category: "Stylistic Issues",
20             recommended: false,
21             url: "https://eslint.org/docs/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 targetParent = options.ignoreNonDeclaration ? ["VariableDeclarator"] : ["AssignmentExpression", "VariableDeclarator"];
49
50         return {
51             AssignmentExpression(node) {
52                 if (targetParent.indexOf(node.parent.type) !== -1) {
53                     context.report({
54                         node,
55                         messageId: "unexpectedChain"
56                     });
57                 }
58             }
59         };
60
61     }
62 };