Skip to content

Commit

Permalink
Prepare 1.0.15 (#12)
Browse files Browse the repository at this point in the history
* add support for arrowfunctions, add test case for #7
* insert a TODO, bump version
* run tests on different versions, enable greenkeeper
* remove super-old nodejs version
  • Loading branch information
mozfreddyb committed Sep 30, 2016
1 parent 5aebdb0 commit 3a0ff06
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: node_js
node_js:
- 0.10
- "4"
- "node"
branches:
only:
- master
- /^greenkeeper-.*$/
before_script:
- npm run lint
5 changes: 3 additions & 2 deletions lib/rules/no-unsafe-innerhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ module.exports = function (context) {
}
}
} else if (expression.type === "TaggedTemplateExpression") {
// context.getSource(expression.tag) is the function name
if (VALID_ESCAPERS.indexOf(context.getSource(expression.tag)) !== -1) {
//TODO avoid code-duplication with CallExpression-case below.
var functionName = context.getSource(expression.tag);
if (VALID_ESCAPERS.indexOf(functionName) !== -1) {
allowed = true;
} else {
allowed = false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eslint-plugin-no-unsafe-innerhtml",
"description": "custom ESLint rule to disallows unsafe innerHTML, outerHTML and insertAdjacentHTML",
"version": "1.0.14",
"version": "1.0.15",
"author": {
"name": "Frederik Braun"
},
Expand Down
12 changes: 11 additions & 1 deletion tests/rules/no-unsafe-innerhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var RuleTester = require("eslint").RuleTester;

var eslintTester = new RuleTester();

var features = { templateStrings: true, spread: true };
var features = { templateStrings: true, spread: true, arrowFunctions: true };

eslintTester.run("no-unsafe-innerhtml", rule, {

Expand Down Expand Up @@ -286,6 +286,16 @@ eslintTester.run("no-unsafe-innerhtml", rule, {
}
],
ecmaFeatures: features
},
{
code: "y.innerHTML = ((arrow_function)=>null)`some HTML`",
errors: [
{
message: "Unsafe assignment to innerHTML",
type: "AssignmentExpression"
}
],
ecmaFeatures: features
}
]
});

0 comments on commit 3a0ff06

Please sign in to comment.