Skip to content

Commit 398e38b

Browse files
author
Jamund Ferguson
committed
New: ES6 Support for demo (fixes eslint#80)
1 parent c861634 commit 398e38b

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

demo/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ <h3>Environments</h3>
3737

3838
</div>
3939
</div>
40+
<div class="row">
41+
<div class="col-md-12">
42+
<h3>ECMA Features</h3>
43+
</div>
44+
</div>
45+
<div class="row ecmaFeatures">
46+
<div class="col-md-12 list">
47+
48+
</div>
49+
</div>
4050
<div class="row">
4151
<div class="col-md-12">
4252
<h3>Rules</h3>

js/app/demo.js

+30-5
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,17 @@ require([
9494
}));
9595
}
9696

97-
function populateConfiguration(rules, environments) {
97+
function populateConfiguration(rules, environments, ecmaFeatures) {
98+
var checkbox;
99+
100+
for (var feature in ecmaFeatures) {
101+
checkbox = $('<div class="checkbox-inline"><label><input class="feature" type="checkbox" />' + feature +'</label></div>');
102+
$('input', checkbox).attr('id', feature).prop('checked', ecmaFeatures[feature]);
103+
$('.ecmaFeatures .list').append(checkbox);
104+
}
105+
98106
for (var env in environments) {
99-
var checkbox = $('<div class="checkbox-inline"><label><input type="checkbox" />' + env +'</label></div>');
107+
checkbox = $('<div class="checkbox-inline"><label><input type="checkbox" />' + env +'</label></div>');
100108
$('input', checkbox).attr('id', env).prop('checked', environments[env]);
101109
$('.environments .list').append(checkbox);
102110
}
@@ -108,7 +116,7 @@ require([
108116
parent = $('<div class="col-md-4"></div>');
109117
$('.rules').append(parent);
110118
}
111-
var checkbox = $('<div class="checkbox"><label><input type="checkbox" />' + rule +'</label></div>');
119+
checkbox = $('<div class="checkbox"><label><input type="checkbox" />' + rule +'</label></div>');
112120
checkbox.popover({
113121
title: rule,
114122
content: function() {
@@ -147,8 +155,14 @@ require([
147155
i = 0;
148156
}
149157
}
158+
150159
$('#configuration .btn').click(function() {
151-
var environments = {}, rules = {};
160+
var environments = {}, rules = {}, ecmaFeatures = {};
161+
$('.ecmaFeatures input').each(function() {
162+
var name = $(this).attr('id');
163+
var value = $(this).is(':checked');
164+
ecmaFeatures[name] = value;
165+
});
152166
$('.environments input').each(function() {
153167
var name = $(this).attr('id');
154168
var value = $(this).is(':checked');
@@ -162,7 +176,9 @@ require([
162176

163177
OPTIONS.rules = rules;
164178
OPTIONS.env = environments;
179+
OPTIONS.ecmaFeatures = ecmaFeatures;
165180
localStorage.rules = JSON.stringify(rules);
181+
localStorage.ecmaFeatures = JSON.stringify(ecmaFeatures);
166182
localStorage.env = JSON.stringify(environments);
167183
verify();
168184
$("#configuration").collapse('hide');
@@ -176,7 +192,16 @@ require([
176192
if (localStorage.env) {
177193
OPTIONS.env = JSON.parse(localStorage.env);
178194
}
179-
populateConfiguration(OPTIONS.rules, OPTIONS.env);
195+
if (localStorage.ecmaFeatures) {
196+
OPTIONS.ecmaFeatures = JSON.parse(localStorage.ecmaFeatures);
197+
}
198+
199+
// make sure es6 env & modules features are available
200+
OPTIONS.env.es6 = OPTIONS.env.es6 || false;
201+
OPTIONS.ecmaFeatures = OPTIONS.ecmaFeatures || {};
202+
OPTIONS.ecmaFeatures.modules = OPTIONS.ecmaFeatures.module || false;
203+
204+
populateConfiguration(OPTIONS.rules, OPTIONS.env, OPTIONS.ecmaFeatures);
180205

181206
var editor = edit(document.getElementById('editor'));
182207

styles/demo.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
}
1111

12-
.environments .list label {
12+
.list label {
1313
font-weight: 400;
1414
}
1515

@@ -23,4 +23,4 @@
2323

2424
.rules .radio+.radio, .rules .checkbox+.checkbox {
2525
margin-top: inherit;
26-
}
26+
}

0 commit comments

Comments
 (0)