* Process an inline linting directive * * @param {Token} directiveToken - the directive-bearing comment token * @param {Token} previous - the token that preceeds the directive
(directiveToken, previous)
| 4839 | * @param {Token} previous - the token that preceeds the directive |
| 4840 | */ |
| 4841 | function lintingDirective(directiveToken, previous) { |
| 4842 | var body = directiveToken.body.split(",") |
| 4843 | .map(function(s) { return s.trim(); }); |
| 4844 | var predef = {}; |
| 4845 | |
| 4846 | if (directiveToken.type === "falls through") { |
| 4847 | previous.caseFallsThrough = true; |
| 4848 | return; |
| 4849 | } |
| 4850 | |
| 4851 | if (directiveToken.type === "globals") { |
| 4852 | body.forEach(function(item, idx) { |
| 4853 | var parts = item.split(":"); |
| 4854 | var key = parts[0].trim(); |
| 4855 | |
| 4856 | if (key === "-" || !key.length) { |
| 4857 | // Ignore trailing comma |
| 4858 | if (idx > 0 && idx === body.length - 1) { |
| 4859 | return; |
| 4860 | } |
| 4861 | error("E002", directiveToken); |
| 4862 | return; |
| 4863 | } |
| 4864 | |
| 4865 | if (key.charAt(0) === "-") { |
| 4866 | key = key.slice(1); |
| 4867 | |
| 4868 | JSHINT.blacklist[key] = key; |
| 4869 | delete predefined[key]; |
| 4870 | } else { |
| 4871 | predef[key] = parts.length > 1 && parts[1].trim() === "true"; |
| 4872 | } |
| 4873 | }); |
| 4874 | |
| 4875 | combine(predefined, predef); |
| 4876 | |
| 4877 | for (var key in predef) { |
| 4878 | if (_.has(predef, key)) { |
| 4879 | declared[key] = directiveToken; |
| 4880 | } |
| 4881 | } |
| 4882 | } |
| 4883 | |
| 4884 | if (directiveToken.type === "exported") { |
| 4885 | body.forEach(function(e, idx) { |
| 4886 | if (!e.length) { |
| 4887 | // Ignore trailing comma |
| 4888 | if (idx > 0 && idx === body.length - 1) { |
| 4889 | return; |
| 4890 | } |
| 4891 | error("E002", directiveToken); |
| 4892 | return; |
| 4893 | } |
| 4894 | |
| 4895 | state.funct["(scope)"].addExported(e); |
| 4896 | }); |
| 4897 | } |
| 4898 |
no test coverage detected
searching dependent graphs…