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