File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55'use strict'
66const TemplateLinter = require ( 'ember-template-lint' )
7- const linter = new TemplateLinter ( )
7+ const fs = require ( 'fs' )
88
99//------------------------------------------------------------------------------
1010// Rule Definition
1111//------------------------------------------------------------------------------
1212
1313module . exports = {
14+
1415 meta : {
1516 docs : {
1617 description :
1718 'If you see some hbs`<h1>handlebars templates</h1>`, pass it through a linter.' ,
1819 category : 'Literal linting' ,
1920 recommended : false
2021 } ,
21- fixable : null , // or "code" or "whitespace"
22+ fixable : null ,
2223 schema : [
23- // fill in your schema
24+ {
25+ oneOf : [
26+ {
27+ enum : [ 'tab' ]
28+ } ,
29+ {
30+ type : 'integer' ,
31+ minimum : 0
32+ }
33+ ]
34+ } ,
35+ {
36+ type : 'object' ,
37+ properties : {
38+ 'ConfigFile' : {
39+ type : 'string'
40+ } ,
41+ } ,
42+ additionalProperties : false ,
43+ } ,
2444 ]
2545 } ,
2646
2747 create : function ( context ) {
48+ let config = { }
49+ let linter
50+ if ( context . options . length > 1 ) {
51+ const extendedOptions = context . options [ 1 ]
52+ const filename = extendedOptions . ConfigFile
53+ if ( filename && fs . existsSync ( filename ) ) {
54+ config = JSON . parse ( fs . readFileSync ( filename ) )
55+ linter = new TemplateLinter ( { config} )
56+ }
57+ }
58+ if ( ! linter ) {
59+ linter = new TemplateLinter ( )
60+ }
61+
2862 //----------------------------------------------------------------------
2963 // Public
3064 //----------------------------------------------------------------------
Original file line number Diff line number Diff line change 11{
22 "name" : " eslint-plugin-hbs" ,
3- "version" : " 0.0.5 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " Provide linting for hbs template literals inside of JavaScript" ,
55 "keywords" : [
66 " eslint" ,
You can’t perform that action at this time.
0 commit comments