12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- "use strict";
- module.exports = {
- meta: {
- type: "suggestion",
- defaultOptions: [{
- ignoreNonDeclaration: false
- }],
- docs: {
- description: "Disallow use of chained assignment expressions",
- recommended: false,
- url: "https://eslint.org/docs/latest/rules/no-multi-assign"
- },
- schema: [{
- type: "object",
- properties: {
- ignoreNonDeclaration: {
- type: "boolean"
- }
- },
- additionalProperties: false
- }],
- messages: {
- unexpectedChain: "Unexpected chained assignment."
- }
- },
- create(context) {
- const [{ ignoreNonDeclaration }] = context.options;
- const selectors = [
- "VariableDeclarator > AssignmentExpression.init",
- "PropertyDefinition > AssignmentExpression.value"
- ];
- if (!ignoreNonDeclaration) {
- selectors.push("AssignmentExpression > AssignmentExpression.right");
- }
- return {
- [selectors](node) {
- context.report({
- node,
- messageId: "unexpectedChain"
- });
- }
- };
- }
- };
|