Skip to content

Commit eb5fe33

Browse files
committed
Adding ability to supply different config files
1 parent 9663cc2 commit eb5fe33

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

lib/rules/check-hbs-template-literals.js

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,61 @@
44
*/
55
'use strict'
66
const TemplateLinter = require('ember-template-lint')
7-
const linter = new TemplateLinter()
7+
const fs = require('fs')
88

99
//------------------------------------------------------------------------------
1010
// Rule Definition
1111
//------------------------------------------------------------------------------
1212

1313
module.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
//----------------------------------------------------------------------

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

0 commit comments

Comments
 (0)