Skip to content

Commit 96156f5

Browse files
authored
Merge pull request #29 from chadhietala/add-docs
Adding documentation for rules
2 parents fabc542 + 7a798d7 commit 96156f5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/rules/linkedin/no-unguarded-document.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
/**
2+
* @fileOverview Disallow the use of unguarded document references.
3+
* @author Steve Calvert
4+
*/
5+
'use strict';
6+
17
const { get } = require('../../utils/get');
28
const { isBrowser, isEnvironmentBrowser, getEnvironmentImportBinding } = require('../../utils/linkedin/bpr');
39
const { isInActions, isInteractive } = require('../../utils/interactive');
410
const { collectObjectPatternBindings } = require('../../utils/destructed-binding');
511

612
const MESSAGE = 'Do not use unguarded document references. Please see the following guide for more infromation: http://github.com/chadhietala/ember-best-practices/files/guides/no-unguarded-document.md';
713

14+
/**
15+
* Determines if the current node is a document reference.
16+
* @param {ASTNode} node The identifier node.
17+
* @returns {Boolean} Returns true if a document reference is found, else false.
18+
*/
819
function isDocumentReference(node) {
920
return get(node, 'callee.object.name') === 'document';
1021
}
1122

1223
module.exports = {
24+
docs: {
25+
description: 'Disallow the use of unguarded document references',
26+
category: 'Best Practices',
27+
recommended: false
28+
},
1329
meta: {
1430
message: MESSAGE
1531
},

lib/rules/linkedin/no-unguarded-window.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
/**
2+
* @fileOverview Disallow the use of unguarded window references.
3+
* @author Steve Calvert
4+
*/
5+
'use strict';
6+
17
const { get } = require('../../utils/get');
28
const { isBrowser, isEnvironmentBrowser, getEnvironmentImportBinding } = require('../../utils/linkedin/bpr');
39
const { isInActions, isInteractive } = require('../../utils/interactive');
410
const { collectObjectPatternBindings } = require('../../utils/destructed-binding');
511

612
const MESSAGE = 'Do not use unguarded window references. Please see the following guide for more infromation: http://github.com/chadhietala/ember-best-practices/files/guides/no-unguarded-window.md';
713

14+
/**
15+
* Determines if the current node is a window reference.
16+
* @param {ASTNode} node The identifier node.
17+
* @returns {Boolean} Returns true if a window reference is found, else false.
18+
*/
819
function isWindowReference(node) {
920
return get(node, 'object.name') === 'window';
1021
}
1122

1223
module.exports = {
24+
docs: {
25+
description: 'Disallow the use of unguarded document references',
26+
category: 'Best Practices',
27+
recommended: false
28+
},
1329
meta: {
1430
message: MESSAGE
1531
},

0 commit comments

Comments
 (0)