Skip to content

Commit b93de25

Browse files
committed
Linted
1 parent 31bb3e8 commit b93de25

File tree

4 files changed

+76
-81
lines changed

4 files changed

+76
-81
lines changed

src/directives/sf-array.directive.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var runSync = function(scope, tmpl) {
1212

1313
describe('sf-array.directive.js', function() {
1414
var exampleSchema;
15+
var tmpl;
1516
beforeEach(module('schemaForm'));
1617
beforeEach(
1718
module(function($sceProvider) {
@@ -76,7 +77,7 @@ describe('sf-array.directive.js', function() {
7677

7778
inject(function($compile, $rootScope) {
7879
var scope = $rootScope.$new();
79-
scope.model = { names: [{ name: "0"}, {name: "1"}, {name: "2"}, {name: "3"}]};
80+
scope.model = { names: [{ name: "0" }, { name: "1" }, { name: "2" }, { name: "3" }]};
8081

8182
scope.schema = exampleSchema;
8283

@@ -97,7 +98,7 @@ describe('sf-array.directive.js', function() {
9798
scope.model.names[1].name.should.equal("2");
9899
scope.model.names[2].name.should.equal("3");
99100
done();
100-
}, 0)
101+
}, 0);
101102
});
102103
});
103104
});

src/directives/sf-field.directive.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function($parse, $compile, $interpolate, sfErrorMessage, sfPath,
5959
if(typeof key[key.length-1] === 'number' && scope.form.key.length >= 1) {
6060
let trim = scope.form.key.length - key.length;
6161
scope.completeKey =
62-
trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
62+
trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
6363
}
6464
else {
6565
scope.completeKey = scope.form.key.slice();
@@ -308,31 +308,32 @@ export default function($parse, $compile, $interpolate, sfErrorMessage, sfPath,
308308

309309
// If the entire schema form is destroyed we don't touch the model
310310
if (!scope.externalDestructionInProgress) {
311-
var destroyStrategy = form.destroyStrategy ||
311+
const destroyStrategy = form.destroyStrategy ||
312312
(scope.options && scope.options.destroyStrategy) || 'remove';
313313
// No key no model, and we might have strategy 'retain'
314314
if (key && destroyStrategy !== 'retain') {
315-
316315
// Type can also be a list in JSON Schema
317-
var type = (form.schema && form.schema.type) || '';
316+
const type = (form.schema && form.schema.type) || '';
318317

319318
// Empty means '',{} and [] for appropriate types and undefined for the rest
320319
let value;
321320
if (destroyStrategy === 'empty') {
322321
value = type.indexOf('string') !== -1 ? '' :
323322
type.indexOf('object') !== -1 ? {} :
324323
type.indexOf('array') !== -1 ? [] : undefined;
325-
} else if (destroyStrategy === 'null') {
324+
}
325+
else if (destroyStrategy === 'null') {
326326
value = null;
327327
}
328328

329329
if (value !== undefined) {
330330
sfSelect(key, scope.model, value);
331-
} else {
331+
}
332+
else {
332333
// Get the object parent object
333334
let obj = scope.model;
334335
if (key.length > 1) {
335-
obj = sfSelect(key.slice(0, key.length - 1), obj)
336+
obj = sfSelect(key.slice(0, key.length - 1), obj);
336337
}
337338

338339
// parent can be undefined if the form hasn't been filled out

src/directives/sf-field.directive.spec.js

+53-51
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,84 @@
1+
/* eslint-disable quotes, no-var */
2+
/* disabling quotes makes it easier to copy tests into the example app */
13
chai.should();
24

35
var runSync = function (scope, tmpl) {
46
var directiveScope = tmpl.isolateScope();
5-
var stub = sinon.stub(directiveScope, 'resolveReferences', function(schema, form) {
7+
sinon.stub(directiveScope, 'resolveReferences', function(schema, form) {
68
directiveScope.render(schema, form);
79
});
810
scope.$apply();
9-
}
11+
};
1012

11-
describe('sf-field.directive.js',function() {
13+
describe('sf-field.directive.js', function() {
1214
beforeEach(module('schemaForm'));
1315
beforeEach(
14-
module(function($sceProvider){
16+
module(function($sceProvider) {
1517
$sceProvider.enabled(false);
1618
})
1719
);
1820

1921
var keyTests = [
2022
{
21-
name: 'array of objects',
22-
targetKey: ['arrayOfObjects', 0, 'stringVal'],
23+
"name": "array of objects",
24+
"targetKey": [ "arrayOfObjects", 0, "stringVal" ],
2325

24-
schema: {
25-
type: 'object',
26-
properties: {
27-
arrayOfObjects: {
28-
type: 'array',
29-
items: {
30-
type: 'object',
31-
properties: {
32-
stringVal: {
33-
type: 'string',
34-
'x-schema-form': {
35-
htmlClass: 'targetKey'
36-
}
37-
}
38-
}
39-
}
40-
}
41-
}
26+
"schema": {
27+
"type": "object",
28+
"properties": {
29+
"arrayOfObjects": {
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"stringVal": {
35+
"type": "string",
36+
"x-schema-form": {
37+
"htmlClass": "targetKey",
38+
},
39+
},
40+
},
41+
},
42+
},
43+
},
4244
},
4345

44-
form: [
46+
"form": [
4547
{
46-
key: 'arrayOfObjects',
47-
items: [
48+
"key": "arrayOfObjects",
49+
"items": [
4850
{
49-
key: 'arrayOfObjects[].stringVal'
50-
}
51-
]
52-
}
53-
]
51+
"key": "arrayOfObjects[].stringVal",
52+
},
53+
],
54+
},
55+
],
5456
},
5557

5658
{
57-
name: 'array of strings',
58-
targetKey: ['arrayOfStrings', 0],
59+
"name": "array of strings",
60+
"targetKey": [ "arrayOfStrings", 0 ],
5961

60-
schema: {
61-
type: 'object',
62-
properties: {
63-
arrayOfStrings: {
64-
type: 'array',
65-
items: {
66-
type: 'string',
67-
'x-schema-form': {
68-
htmlClass: 'targetKey'
69-
}
70-
}
71-
}
72-
}
73-
}
74-
}
62+
"schema": {
63+
"type": "object",
64+
"properties": {
65+
"arrayOfStrings": {
66+
"type": "array",
67+
"items": {
68+
"type": "string",
69+
"x-schema-form": {
70+
htmlClass: "targetKey",
71+
},
72+
},
73+
},
74+
},
75+
},
76+
},
7577
];
7678

7779
keyTests.forEach(function(keyTest) {
7880
it('should generate correct form keys for ' + keyTest.name, function(done) {
79-
inject(function($compile,$rootScope) {
81+
inject(function($compile, $rootScope) {
8082
var scope = $rootScope.$new();
8183
scope.model = {};
8284
scope.schema = keyTest.schema;
@@ -93,7 +95,7 @@ describe('sf-field.directive.js',function() {
9395

9496
if (keyTest.form) {
9597
it('should generate correct form keys for ' + keyTest.name + ' with user specified form', function(done) {
96-
inject(function($compile,$rootScope) {
98+
inject(function($compile, $rootScope) {
9799
var scope = $rootScope.$new();
98100
scope.model = {};
99101
scope.schema = keyTest.schema;

src/services/schema-form.provider.spec.js

+12-21
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ describe('schema-form.provider.js', function() {
142142
"attributes",
143143
],
144144
"type": "fieldset",
145-
"key": [
146-
"attributes",
147-
],
148145
"items": [
149146
{
150147
"title": "Eye color",
@@ -193,10 +190,6 @@ describe('schema-form.provider.js', function() {
193190
"shoulders",
194191
],
195192
"type": "fieldset",
196-
"key": [
197-
"attributes",
198-
"shoulders",
199-
],
200193
"items": [
201194
{
202195
"title": "left",
@@ -573,34 +566,33 @@ describe('schema-form.provider.js', function() {
573566
properties: {
574567
name: {
575568
title: "Name",
576-
type: "string"
569+
type: "string",
577570
},
578571
age: {
579572
title: "Age",
580-
type: "integer"
581-
}
573+
type: "integer",
574+
},
582575
},
583-
required: ["name"]
584-
}
585-
}
576+
required: [ "name" ],
577+
},
578+
},
586579
},
587-
required: ["dependentChildren"]
588-
}
580+
required: [ "dependentChildren" ],
581+
},
589582
},
590-
required: ["peopleLivingWithYou"]
583+
required: [ "peopleLivingWithYou" ],
591584
};
592585

593586
it('merge a schema that defines an array of objects with a form inside a section #900', function() {
594587
inject(function(schemaForm) {
595-
596588
var formInsideSection = [{
597589
type: 'section',
598590
items: [{
599591
key: 'peopleLivingWithYou.dependentChildren',
600592
add: "Add Child",
601593
title: 'Dependent children details',
602-
validationMessage: 'Complete all required fields for at least one child'
603-
}]
594+
validationMessage: 'Complete all required fields for at least one child',
595+
}],
604596
}];
605597

606598
var merged = schemaForm.merge(arrayObjectSchema, formInsideSection);
@@ -615,12 +607,11 @@ describe('schema-form.provider.js', function() {
615607

616608
it('merge a schema that defines an array of objects with a form without a section #900', function() {
617609
inject(function(schemaForm) {
618-
619610
var formWithoutSection = [{
620611
key: 'peopleLivingWithYou.dependentChildren',
621612
add: "Add Child",
622613
title: 'Dependent children details',
623-
validationMessage: 'Complete all required fields for at least one child'
614+
validationMessage: 'Complete all required fields for at least one child',
624615
}];
625616

626617
var merged = schemaForm.merge(arrayObjectSchema, formWithoutSection);

0 commit comments

Comments
 (0)