github-pages-deploy-action/node_modules/eslint/lib/rules/no-sync.js

66 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2020-03-07 11:45:40 +08:00
/**
* @fileoverview Rule to check for properties whose identifier ends with the string Sync
* @author Matt DuVall<http://mattduvall.com/>
*/
/* jshint node:true */
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
2020-05-15 05:33:08 +08:00
deprecated: true,
2020-06-06 22:11:37 +08:00
replacedBy: [],
2020-05-15 05:33:08 +08:00
2020-03-07 11:45:40 +08:00
type: "suggestion",
docs: {
description: "disallow synchronous methods",
category: "Node.js and CommonJS",
recommended: false,
url: "https://eslint.org/docs/rules/no-sync"
},
schema: [
{
type: "object",
properties: {
allowAtRootLevel: {
type: "boolean",
default: false
}
},
additionalProperties: false
}
2020-05-15 05:33:08 +08:00
],
messages: {
noSync: "Unexpected sync method: '{{propertyName}}'."
}
2020-03-07 11:45:40 +08:00
},
create(context) {
const selector = context.options[0] && context.options[0].allowAtRootLevel
? ":function MemberExpression[property.name=/.*Sync$/]"
: "MemberExpression[property.name=/.*Sync$/]";
return {
[selector](node) {
context.report({
node,
2020-05-15 05:33:08 +08:00
messageId: "noSync",
2020-03-07 11:45:40 +08:00
data: {
propertyName: node.property.name
}
});
}
};
}
};