ember-template-lint
Advanced tools
Comparing version 0.5.1 to 0.5.2
Changelog | ||
========= | ||
## v0.5.2 | ||
- Add `fix` information to the results object for: | ||
- `html-comments` | ||
- `self-closing-void-elements` | ||
- `deprecated-each-syntax` | ||
- Add support for context shifting `{{#each` (i.e. `{{#each posts}}`) to the `deprecated-each-syntax`. | ||
## v0.5.1 | ||
@@ -5,0 +13,0 @@ |
@@ -86,3 +86,3 @@ 'use strict'; | ||
BasePlugin.prototype.isDisabled = function() { | ||
return this.config === false; | ||
return !this.config; | ||
}; | ||
@@ -89,0 +89,0 @@ |
@@ -14,8 +14,17 @@ 'use strict'; | ||
return astInfo.isBlockStatement(node) && | ||
node.path.original === 'each' && | ||
node.params.length > 1 && | ||
node.params[1].original === 'in'; | ||
node.path.original === 'each'; | ||
}; | ||
DeprecatedEachSyntax.prototype.process = function(node) { | ||
var isEachIn = node.params.length > 1 && node.params[1].original === 'in'; | ||
var isEachContextShifting = node.params.length === 1 && node.program.blockParams.length === 0; | ||
if (isEachIn) { | ||
this.processEachIn(node); | ||
} else if (isEachContextShifting) { | ||
this.processEachContextShifting(node); | ||
} | ||
}; | ||
DeprecatedEachSyntax.prototype.processEachIn = function(node) { | ||
var params = node.params; | ||
@@ -28,9 +37,3 @@ var singular = params[0].original; | ||
var message = [ | ||
'Deprecated {{#each}} usage ', | ||
'Actual: ' + actual, | ||
'Expected (rewrite the template to this): ' + expected, | ||
'The `#each in` syntax was deprecated in 1.11 and removed in Ember 2.0.', | ||
'See the deprecation guide at ' + DEPRECATION_URL | ||
].join('\n'); | ||
var message = 'Deprecated {{#each}} usage. See the deprecation guide at ' + DEPRECATION_URL; | ||
@@ -41,7 +44,33 @@ this.log({ | ||
column: node.loc && node.loc.start.column, | ||
source: this.sourceForNode(node) | ||
source: actual, | ||
fix: { | ||
text: expected | ||
} | ||
}); | ||
}; | ||
DeprecatedEachSyntax.prototype.processEachContextShifting = function(node) { | ||
var params = node.params; | ||
var collection = params[0].original; | ||
var actual = '{{#each ' + collection + '}}'; | ||
var expected = '{{#each ' + collection + ' as |item|}}'; | ||
var message = 'Deprecated {{#each}} usage. See the deprecation guide at ' + DEPRECATION_URL; | ||
this.log({ | ||
message: message, | ||
line: node.loc && node.loc.start.line, | ||
column: node.loc && node.loc.start.column, | ||
source: actual, | ||
fix: { | ||
text: expected | ||
} | ||
}); | ||
}; | ||
return DeprecatedEachSyntax; | ||
}; | ||
module.exports.DEPRECATION_URL = DEPRECATION_URL; |
@@ -35,3 +35,6 @@ 'use strict'; | ||
column: node.loc && node.loc.start.column, | ||
source: '<!--' + node.value + '-->' | ||
source: '<!--' + node.value + '-->', | ||
fix: { | ||
text: '{{!' + node.value + '}}' | ||
} | ||
}); | ||
@@ -38,0 +41,0 @@ }; |
@@ -53,9 +53,12 @@ 'use strict'; | ||
if (sourceEndTwoCharacters === '/>') { | ||
var warning = 'Self-closing a void element is redundant'; | ||
var expected = source.slice(0, -2) + '>'; | ||
this.log({ | ||
message: warning, | ||
message: 'Self-closing a void element is redundant', | ||
line: node.loc.start.line, | ||
column: node.loc.start.column, | ||
source: this.sourceForNode(node) | ||
source: source, | ||
fix: { | ||
text: expected | ||
} | ||
}); | ||
@@ -62,0 +65,0 @@ } |
{ | ||
"name": "ember-template-lint", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Lint your templates.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
'use strict'; | ||
var generateRuleTests = require('../../../helpers/rule-test-harness'); | ||
var DEPRECATION_URL = require('../../../../ext/plugins/deprecations/lint-deprecated-each-syntax').DEPRECATION_URL; | ||
var message = 'Deprecated {{#each}} usage. See the deprecation guide at ' + DEPRECATION_URL; | ||
generateRuleTests({ | ||
name: 'deprecated-each-syntax', | ||
config: true, | ||
good: [ | ||
@@ -20,10 +25,28 @@ { | ||
rule: 'deprecated-each-syntax', | ||
message: 'Deprecated {{#each}} usage \nActual: {{#each post in posts}}\nExpected (rewrite the template to this): {{#each posts as |post|}}\nThe `#each in` syntax was deprecated in 1.11 and removed in Ember 2.0.\nSee the deprecation guide at http://emberjs.com/deprecations/v1.x/#toc_code-in-code-syntax-for-code-each-code', | ||
message: message, | ||
moduleId: 'layout.hbs', | ||
source: '{{#each post in posts}}{{post.name}}{{/each}}', | ||
source: '{{#each post in posts}}', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '{{#each posts as |post|}}' | ||
} | ||
} | ||
}, | ||
{ | ||
template: '{{#each posts}}{{name}}{{/each}}', | ||
result: { | ||
rule: 'deprecated-each-syntax', | ||
message: message, | ||
moduleId: 'layout.hbs', | ||
source: '{{#each posts}}', | ||
line: 1, | ||
column: 0, | ||
fix: { | ||
text: '{{#each posts as |item|}}' | ||
} | ||
} | ||
} | ||
] | ||
}); |
@@ -27,3 +27,6 @@ 'use strict'; | ||
line: 1, | ||
column: 3 | ||
column: 3, | ||
fix: { | ||
text: '{{! comment here }}' | ||
} | ||
} | ||
@@ -40,3 +43,6 @@ }, | ||
line: 1, | ||
column: 3 | ||
column: 3, | ||
fix: { | ||
text: '{{!comment here}}' | ||
} | ||
} | ||
@@ -43,0 +49,0 @@ } |
@@ -35,3 +35,3 @@ 'use strict'; | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -41,3 +41,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<area>' | ||
} | ||
} | ||
@@ -49,3 +52,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -55,3 +58,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<base>' | ||
} | ||
} | ||
@@ -63,3 +69,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -69,3 +75,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<br>' | ||
} | ||
} | ||
@@ -77,3 +86,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -83,3 +92,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<col>' | ||
} | ||
} | ||
@@ -91,3 +103,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -97,3 +109,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<command>' | ||
} | ||
} | ||
@@ -105,3 +120,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -111,3 +126,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<embed>' | ||
} | ||
} | ||
@@ -119,3 +137,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -125,3 +143,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<hr>' | ||
} | ||
} | ||
@@ -133,3 +154,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -139,3 +160,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<img>' | ||
} | ||
} | ||
@@ -147,3 +171,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -153,3 +177,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<input>' | ||
} | ||
} | ||
@@ -161,3 +188,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -167,3 +194,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<keygen>' | ||
} | ||
} | ||
@@ -175,3 +205,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -181,3 +211,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<link>' | ||
} | ||
} | ||
@@ -189,3 +222,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -195,3 +228,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<meta>' | ||
} | ||
} | ||
@@ -203,3 +239,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -209,3 +245,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<param>' | ||
} | ||
} | ||
@@ -217,3 +256,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -223,3 +262,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<source>' | ||
} | ||
} | ||
@@ -231,3 +273,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -237,3 +279,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<track>' | ||
} | ||
} | ||
@@ -246,3 +291,3 @@ }, | ||
result: { | ||
rule: 'lint-self-closing-void-elements', | ||
rule: 'self-closing-void-elements', | ||
message: 'Self-closing a void element is redundant', | ||
@@ -252,3 +297,6 @@ moduleId: 'layout.hbs', | ||
line: 1, | ||
column: 0 | ||
column: 0, | ||
fix: { | ||
text: '<wbr>' | ||
} | ||
} | ||
@@ -255,0 +303,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81980
2336