Skip to content

Commit

Permalink
style: fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
assisrafael committed Mar 28, 2016
1 parent 5da0adb commit 0214bb7
Show file tree
Hide file tree
Showing 54 changed files with 283 additions and 204 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!node_modules
19 changes: 8 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"commonjs": true,
"es6": true,
"node": true,
"jasmine": true
"jasmine": true,
"protractor": true
},
"globals": {
"angular": true
"angular": true,
"TestUtil": true
},
"extends": "eslint:recommended",
"rules": {
Expand Down Expand Up @@ -76,7 +78,7 @@
}],
"init-declarations": 0,
"key-spacing": 0,
"keyword-spacing": 0,
"keyword-spacing": 2,
"linebreak-style": [
2,
"unix"
Expand Down Expand Up @@ -154,12 +156,7 @@
"no-sync": 2,
"no-ternary": 0,
"no-throw-literal": 2,
"no-trailing-spaces": [
2,
{
"skipBlankLines": true
}
],
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-underscore-dangle": 2,
Expand Down Expand Up @@ -210,7 +207,7 @@
],
"require-jsdoc": 0,
"require-yield": 2,
"semi": 0,
"semi": [2, "always"],
"semi-spacing": [
2,
{
Expand All @@ -220,7 +217,7 @@
],
"sort-imports": 2,
"sort-vars": 0,
"space-before-blocks": 2,
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [
2,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"homepage": "http://github.com/assisrafael/angular-input-masks",
"scripts": {
"lint": "eslint *.js src/**/*.js config/*.js --fix",
"lint": "eslint *.js src/ config/ --fix",
"test:unit": "karma start config/karma.conf.js --single-run",
"test:unit:watch": "karma start config/karma.conf.js --auto-watch",
"test:e2e:prepare": "webdriver-manager update",
Expand Down
2 changes: 2 additions & 0 deletions src/angular-input-masks.br.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = angular.module('ui.utils.masks', [
require('./global/global-masks'),
require('./br/br-masks')
Expand Down
2 changes: 2 additions & 0 deletions src/angular-input-masks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = angular.module('ui.utils.masks', [
require('./global/global-masks'),
require('./br/br-masks'),
Expand Down
2 changes: 2 additions & 0 deletions src/angular-input-masks.us.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = angular.module('ui.utils.masks', [
require('./global/global-masks'),
require('./us/us-masks')
Expand Down
2 changes: 2 additions & 0 deletions src/br/boleto-bancario/boleto-bancario.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var maskFactory = require('mask-factory');

Expand Down
2 changes: 2 additions & 0 deletions src/br/boleto-bancario/boleto-bancario.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-boleto-bancario-mask', function() {
Expand Down
2 changes: 2 additions & 0 deletions src/br/car-plate/car-plate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var maskFactory = require('mask-factory');

Expand Down
5 changes: 2 additions & 3 deletions src/br/car-plate/car-plate.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui.utils.masks.br.car-plate', function() {
it('should load the demo page', function() {
Expand Down Expand Up @@ -40,8 +40,7 @@ describe('ui.utils.masks.br.car-plate', function() {
});

it('should apply a Car Plate mask in a model with default value:', function() {
var input = element(by.model('initializedCarPlate')),
value = element(by.binding('initializedCarPlate'));
var input = element(by.model('initializedCarPlate'));

expect(input.getAttribute('value')).toEqual('ABC-2010');
});
Expand Down
2 changes: 2 additions & 0 deletions src/br/car-plate/car-plate.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-car-plate-mask', function() {
Expand Down
2 changes: 2 additions & 0 deletions src/br/cep/cep.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var maskFactory = require('mask-factory');

Expand Down
5 changes: 2 additions & 3 deletions src/br/cep/cep.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui.utils.masks.br.cep', function() {
it('should load the demo page', function() {
Expand Down Expand Up @@ -42,8 +42,7 @@ describe('ui.utils.masks.br.cep', function() {
});

it('should apply a CEP mask in a model with default value:', function() {
var input = element(by.model('initializedCep')),
value = element(by.binding('initializedCep'));
var input = element(by.model('initializedCep'));

expect(input.getAttribute('value')).toEqual('30112-010');
});
Expand Down
2 changes: 2 additions & 0 deletions src/br/cep/cep.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-cep-mask', function() {
Expand Down
2 changes: 2 additions & 0 deletions src/br/cnpj/cnpj.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var BrV = require('br-validations');
var maskFactory = require('mask-factory');
Expand Down
2 changes: 1 addition & 1 deletion src/br/cnpj/cnpj.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui-br-cnpj:', function() {
it('should load the demo page', function() {
Expand Down
4 changes: 3 additions & 1 deletion src/br/cnpj/cnpj.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-cnpj-mask', function() {
Expand Down Expand Up @@ -29,7 +31,7 @@ describe('ui-br-cnpj-mask', function() {
expect(model.$viewValue).toBe('13.883.875/0001-20');
});

it('should handle corner cases', inject(function($rootScope) {
it('should handle corner cases', angular.mock.inject(function($rootScope) {
var input = TestUtil.compile('<input ng-model="model" ui-br-cnpj-mask>');
var model = input.controller('ngModel');

Expand Down
2 changes: 2 additions & 0 deletions src/br/cpf-cnpj/cpf-cnpj.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var BrV = require('br-validations');
var maskFactory = require('mask-factory');
Expand Down
8 changes: 3 additions & 5 deletions src/br/cpf-cnpj/cpf-cnpj.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui.utils.masks.cpfCnpj', function() {
it('should load the demo page', function() {
Expand Down Expand Up @@ -54,15 +54,13 @@ describe('ui.utils.masks.cpfCnpj', function() {
});

it('should apply a CPFCNPJ mask in a model with default CPF value:', function() {
var input = element(by.model('initializedCpfCnpj1')),
value = element(by.binding('initializedCpfCnpj1'));
var input = element(by.model('initializedCpfCnpj1'));

expect(input.getAttribute('value')).toEqual('563.383.329-58');
});

it('should apply a CPFCNPJ mask in a model with default CNPJ value:', function() {
var input = element(by.model('initializedCpfCnpj2')),
value = element(by.binding('initializedCpfCnpj2'));
var input = element(by.model('initializedCpfCnpj2'));

expect(input.getAttribute('value')).toEqual('23.212.161/0001-44');
});
Expand Down
6 changes: 4 additions & 2 deletions src/br/cpf-cnpj/cpf-cnpj.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-cpfcnpj-mask', function() {
Expand Down Expand Up @@ -29,7 +31,7 @@ describe('ui-br-cpfcnpj-mask', function() {
expect(model.$viewValue).toBe('352.444.576-40');
});

it('should handle corner cases', inject(function($rootScope) {
it('should handle corner cases', angular.mock.inject(function($rootScope) {
var input = TestUtil.compile('<input ng-model="model" ui-br-cpfcnpj-mask>');
var model = input.controller('ngModel');

Expand All @@ -47,7 +49,7 @@ describe('ui-br-cpfcnpj-mask', function() {
});
}));

it('should ignore non digits', function() {
it('should ignore non digits', function() {
var input = TestUtil.compile('<input ng-model="model" ng-model-options="{allowInvalid:true}"' +
' ui-br-cpfcnpj-mask>');
var model = input.controller('ngModel');
Expand Down
2 changes: 2 additions & 0 deletions src/br/cpf/cpf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var BrV = require('br-validations');
var maskFactory = require('mask-factory');
Expand Down
2 changes: 1 addition & 1 deletion src/br/cpf/cpf.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui-br-cpf:', function() {
it('should load the demo page', function() {
Expand Down
4 changes: 3 additions & 1 deletion src/br/cpf/cpf.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

require('../br-masks');

describe('ui-br-cpf-mask', function() {
Expand Down Expand Up @@ -29,7 +31,7 @@ describe('ui-br-cpf-mask', function() {
expect(model.$viewValue).toBe('352.444.576-40');
});

it('should handle corner cases', inject(function($rootScope) {
it('should handle corner cases', angular.mock.inject(function($rootScope) {
var input = TestUtil.compile('<input ng-model="model" ui-br-cpf-mask>');
var model = input.controller('ngModel');

Expand Down
16 changes: 9 additions & 7 deletions src/br/inscricao-estadual/ie.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var StringMask = require('string-mask');
var BrV = require('br-validations');

Expand All @@ -8,7 +10,7 @@ function BrIeMaskDirective($parse) {
'AM': [{mask: new StringMask('00.000.000-0')}],
'AP': [{mask: new StringMask('000000000')}],
'BA': [{chars: 8, mask: new StringMask('000000-00')},
{mask: new StringMask('0000000-00')}],
{mask: new StringMask('0000000-00')}],
'CE': [{mask: new StringMask('00000000-0')}],
'DF': [{mask: new StringMask('00000000000-00')}],
'ES': [{mask: new StringMask('00000000-0')}],
Expand All @@ -20,23 +22,23 @@ function BrIeMaskDirective($parse) {
'PA': [{mask: new StringMask('00-000000-0')}],
'PB': [{mask: new StringMask('00000000-0')}],
'PE': [{chars: 9, mask: new StringMask('0000000-00')},
{mask: new StringMask('00.0.000.0000000-0')}],
{mask: new StringMask('00.0.000.0000000-0')}],
'PI': [{mask: new StringMask('000000000')}],
'PR': [{mask: new StringMask('000.00000-00')}],
'RJ': [{mask: new StringMask('00.000.00-0')}],
'RN': [{chars: 9, mask: new StringMask('00.000.000-0')},
{mask: new StringMask('00.0.000.000-0')}],
{mask: new StringMask('00.0.000.000-0')}],
'RO': [{mask: new StringMask('0000000000000-0')}],
'RR': [{mask: new StringMask('00000000-0')}],
'RS': [{mask: new StringMask('000/0000000')}],
'SC': [{mask: new StringMask('000.000.000')}],
'SE': [{mask: new StringMask('00000000-0')}],
'SP': [{mask: new StringMask('000.000.000.000')},
{mask: new StringMask('-00000000.0/000')}],
{mask: new StringMask('-00000000.0/000')}],
'TO': [{mask: new StringMask('00000000000')}]
};

function clearValue (value) {
function clearValue(value) {
if (!value) {
return value;
}
Expand All @@ -55,7 +57,7 @@ function BrIeMaskDirective($parse) {

var masks = ieMasks[uf];
var i = 0;
while(masks[i].chars && masks[i].chars < clearValue(value).length && i < masks.length - 1) {
while (masks[i].chars && masks[i].chars < clearValue(value).length && i < masks.length - 1) {
i++;
}

Expand All @@ -65,7 +67,7 @@ function BrIeMaskDirective($parse) {
function applyIEMask(value, uf) {
var mask = getMask(uf, value);

if(!mask) {
if (!mask) {
return value;
}

Expand Down
20 changes: 10 additions & 10 deletions src/br/inscricao-estadual/ie.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var StringMask = require('string-mask');
'use strict';

describe('ui.utils.masks.number', function() {
it('should load the demo page', function() {
Expand All @@ -8,8 +8,7 @@ describe('ui.utils.masks.number', function() {

describe('ui-br-ie-mask:', function() {
it('should apply a IE mask in a model with default value:', function() {
var input = element(by.model('initializedIE')),
value = element(by.binding('initializedIE'));
var input = element(by.model('initializedIE'));

expect(input.getAttribute('value')).toEqual('P-35887477.0/971');
});
Expand Down Expand Up @@ -83,9 +82,9 @@ describe('ui.utils.masks.number', function() {
if (i > viewValue.replace(/[^P0-9]/ig,'').length && viewValue2) {
values = viewValue2.split('');
}
var expected = ''
var expected = '';
var count = 0;
while(count < i && values.length > 0) {
while (count < i && values.length > 0) {
var c = values.splice(0,1);
expected += c;
count += /[P0-9]/i.test(c);
Expand All @@ -105,18 +104,19 @@ describe('ui.utils.masks.number', function() {
var viewValue2 = test.viewValue2;

inputUF.all(by.tagName('option')).get(test.option).click();
var i;
var i, erroMsg, expected;
for (i = 0; i < values.length; i++) {
inputIE.sendKeys(values[i]);
var erroMsg = 'Estado: '+test.uf+'; i: '+i+'; key: '+values[i];
var expected = getExpectedViewValue(viewValue, i+1, viewValue2);
erroMsg = 'Estado: '+test.uf+'; i: '+i+'; key: '+values[i];
expected = getExpectedViewValue(viewValue, i+1, viewValue2);
expect(inputIE.getAttribute('value')).toEqual(expected, erroMsg);
expect(value.getText()).toEqual(test.modelValue.substr(0,i+1), erroMsg);
}

for (; i > 0; i--) {
inputIE.sendKeys(BS);
var erroMsg = 'Estado: '+test.uf+'; i: '+i+'; key: BS';
var expected = getExpectedViewValue(viewValue, i-1, viewValue2);
erroMsg = 'Estado: '+test.uf+'; i: '+i+'; key: BS';
expected = getExpectedViewValue(viewValue, i-1, viewValue2);
expect(inputIE.getAttribute('value')).toEqual(expected, erroMsg);
expect(value.getText()).toEqual(test.modelValue.substr(0,i-1), erroMsg);
}
Expand Down
Loading

0 comments on commit 0214bb7

Please sign in to comment.