]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-sync.js
import 8.23.1 source
[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 /** @type {import('../shared/types').Rule} */
14 module.exports = {
15 meta: {
16 deprecated: true,
17
18 replacedBy: [],
19
20 type: "suggestion",
21
22 docs: {
23 description: "Disallow synchronous methods",
24 recommended: false,
25 url: "https://eslint.org/docs/rules/no-sync"
26 },
27
28 schema: [
29 {
30 type: "object",
31 properties: {
32 allowAtRootLevel: {
33 type: "boolean",
34 default: false
35 }
36 },
37 additionalProperties: false
38 }
39 ],
40
41 messages: {
42 noSync: "Unexpected sync method: '{{propertyName}}'."
43 }
44 },
45
46 create(context) {
47 const selector = context.options[0] && context.options[0].allowAtRootLevel
48 ? ":function MemberExpression[property.name=/.*Sync$/]"
49 : "MemberExpression[property.name=/.*Sync$/]";
50
51 return {
52 [selector](node) {
53 context.report({
54 node,
55 messageId: "noSync",
56 data: {
57 propertyName: node.property.name
58 }
59 });
60 }
61 };
62
63 }
64 };