2015-04-29 01:03:05 +08:00
|
|
|
/**
|
|
|
|
* @fileoverview Rule to check for properties whose identifier ends with the string Sync
|
|
|
|
* @author Matt DuVall<http://mattduvall.com/>
|
|
|
|
*/
|
|
|
|
|
2016-01-13 03:50:19 +08:00
|
|
|
/* jshint node:true */
|
2015-04-29 01:03:05 +08:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Rule Definition
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2016-05-01 13:24:35 +08:00
|
|
|
module.exports = {
|
|
|
|
meta: {
|
|
|
|
docs: {
|
|
|
|
description: "disallow synchronous methods",
|
|
|
|
category: "Node.js and CommonJS",
|
|
|
|
recommended: false
|
|
|
|
},
|
2015-04-29 01:03:05 +08:00
|
|
|
|
2016-05-01 13:24:35 +08:00
|
|
|
schema: []
|
|
|
|
},
|
2015-04-29 01:03:05 +08:00
|
|
|
|
2016-05-01 13:24:35 +08:00
|
|
|
create: function(context) {
|
2015-04-29 01:03:05 +08:00
|
|
|
|
2016-05-01 13:24:35 +08:00
|
|
|
return {
|
|
|
|
|
|
|
|
MemberExpression: function(node) {
|
2016-08-14 06:06:43 +08:00
|
|
|
const propertyName = node.property.name,
|
2016-05-01 13:24:35 +08:00
|
|
|
syncRegex = /.*Sync$/;
|
|
|
|
|
|
|
|
if (syncRegex.exec(propertyName) !== null) {
|
|
|
|
context.report(node, "Unexpected sync method: '" + propertyName + "'.");
|
|
|
|
}
|
2015-04-29 01:03:05 +08:00
|
|
|
}
|
2016-05-01 13:24:35 +08:00
|
|
|
};
|
2015-04-29 01:03:05 +08:00
|
|
|
|
2016-05-01 13:24:35 +08:00
|
|
|
}
|
2015-04-29 01:03:05 +08:00
|
|
|
};
|