UNPKG

688 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag non-quoted property names in object literals.
3 * @author Mathias Bynens <http://mathiasbynens.be/>
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15
16 "Property": function(node) {
17 var key = node.key;
18
19 // Check if the property name is quoted
20 if (key.type !== "Literal") {
21 context.report(node, "Non-quoted property `{{key}}` found.", { key: key.name });
22 }
23
24 }
25 };
26
27};