]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-sync.js
ea40df12933b5c994953e484b8db63b4887981ba
[pve-eslint.git] / eslint / lib / rules / no-sync.js
1 /**
2 * @fileoverview Rule to check for properties whose identifier ends with the string Sync
3 * @author Matt DuVall<http://mattduvall.com/>
4 * @deprecated in ESLint v7.0.0
5 */
6
7 "use strict";
8
9 //------------------------------------------------------------------------------
10 // Rule Definition
11 //------------------------------------------------------------------------------
12
13 module.exports = {
14 meta: {
15 deprecated: true,
16
17 replacedBy: [],
18
19 type: "suggestion",
20
21 docs: {
22 description: "disallow synchronous methods",
23 recommended: false,
24 url: "https://eslint.org/docs/rules/no-sync"
25 },
26
27 schema: [
28 {
29 type: "object",
30 properties: {
31 allowAtRootLevel: {
32 type: "boolean",
33 default: false
34 }
35 },
36 additionalProperties: false
37 }
38 ],
39
40 messages: {
41 noSync: "Unexpected sync method: '{{propertyName}}'."
42 }
43 },
44
45 create(context) {
46 const selector = context.options[0] && context.options[0].allowAtRootLevel
47 ? ":function MemberExpression[property.name=/.*Sync$/]"
48 : "MemberExpression[property.name=/.*Sync$/]";
49
50 return {
51 [selector](node) {
52 context.report({
53 node,
54 messageId: "noSync",
55 data: {
56 propertyName: node.property.name
57 }
58 });
59 }
60 };
61
62 }
63 };