chore(lint): add ESLint to repo

Fixes #45
Add ESLint and remove lint errors
This commit is contained in:
Sai Pc 2015-06-17 15:09:03 -07:00
Родитель 8a5d7efcdd
Коммит 3e34e03788
10 изменённых файлов: 49 добавлений и 23 удалений

3
.eslintrc Normal file
Просмотреть файл

@ -0,0 +1,3 @@
{
"extends": "fxa/server"
}

Просмотреть файл

@ -15,4 +15,5 @@ before_install:
script:
- npm run outdated
- grunt lint
- npm test

Просмотреть файл

@ -4,9 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const fs = require('fs');
const path = require('path');
const extract = require('jsxgettext-recursive');
const path = require('path')
const extract = require('jsxgettext-recursive')
// # Globbing
// for performance reasons we're only matching one level down:
@ -14,9 +13,11 @@ const extract = require('jsxgettext-recursive');
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
'use strict';
'use strict'
grunt.loadNpmTasks('grunt-contrib-copy');
require('load-grunt-tasks')(grunt)
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.initConfig({
copy: {
@ -32,10 +33,10 @@ module.exports = function (grunt) {
}]
}
}
});
})
grunt.registerTask('l10n-extract', 'Extract strings from templates for localization.', function () {
var done = this.async();
var done = this.async()
var walker = extract({
'input-dir': path.join(__dirname, 'templates'),
@ -47,7 +48,7 @@ module.exports = function (grunt) {
'.txt': 'handlebars',
'.html': 'handlebars'
}
});
})
walker.on('end', function () {
var jsWalker = extract({
@ -64,14 +65,19 @@ module.exports = function (grunt) {
parsers: {
'.js': 'javascript'
}
});
})
jsWalker.on('end', function () {
done();
});
});
});
done()
})
})
})
grunt.registerTask('default', [ 'copy:strings', 'l10n-extract' ]);
// load local Grunt tasks
grunt.loadTasks('tasks')
};
grunt.registerTask('lint', 'Alias for eslint tasks', ['eslint'])
grunt.registerTask('default', [ 'copy:strings', 'l10n-extract' ])
}

Просмотреть файл

@ -42,7 +42,7 @@ P.all(
res.send(200)
}
else {
log.error({ op: 'send', err: { message: 'invalid type', body: body }})
log.error({ op: 'send', err: { message: 'invalid type', body: req.body }})
res.send(400)
}
next()

Просмотреть файл

@ -27,10 +27,13 @@
"restify": "2.8.2"
},
"devDependencies": {
"eslint-config-fxa": "1.6.0",
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-contrib-copy": "0.5.0",
"grunt-eslint": "15.0.0",
"jsxgettext-recursive": "0.0.5",
"load-grunt-tasks": "3.2.0",
"mailparser": "0.4.4",
"simplesmtp": "0.3.32",
"tap": "0.4.12"

16
tasks/eslint.js Normal file
Просмотреть файл

@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = function (grunt) {
'use strict'
grunt.config('eslint', {
options: {
eslintrc: '.eslintrc'
},
app: [
'*.js', 'bin/*.js', 'tasks/*.js', 'templates/*.js', 'test/**/*.js'
]
})
}

Просмотреть файл

@ -1,7 +1,7 @@
var path = require('path')
var P = require('bluebird')
var handlebars = require('handlebars')
var readFile = P.promisify(require("fs").readFile)
var readFile = P.promisify(require('fs').readFile)
handlebars.registerHelper(
't',

Просмотреть файл

@ -1,6 +1,6 @@
var test = require('tap').test
require('../../translator')(['en','pt_br', 'DE', 'ES_AR', 'ES_cl'], 'en')
require('../../translator')(['en', 'pt_br', 'DE', 'ES_AR', 'ES_cl'], 'en')
.done(
function (translator) {
test(

Просмотреть файл

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var Mail = require('lazysmtp').Mail
var MailParser = require('mailparser').MailParser
var restify = require('restify')
var config = require('rc')(
@ -21,7 +20,6 @@ var config = require('rc')(
// SMTP half
var mail = new Mail(config.mail.host)
var users = {}
function emailName(emailAddress) {
@ -30,13 +28,12 @@ function emailName(emailAddress) {
require('simplesmtp').createSimpleServer(
{
SMTPBanner: "FXATEST"
SMTPBanner: 'FXATEST'
},
function (req) {
var mp = new MailParser({ defaultCharset: 'utf8' })
mp.on('end',
function (mail) {
var uid = mail.headers['x-uid']
var link = mail.headers['x-link']
var rc = mail.headers['x-recovery-code']
var vc = mail.headers['x-verify-code']

Просмотреть файл

@ -32,7 +32,7 @@ module.exports = function (locales, defaultLanguage) {
var supportedLanguages = []
for (var i = 0; i < translations.length; i++) {
var t = translations[i]
var language = i18n.normalizeLanguage(i18n.languageFrom(t.locale_data.messages[""].lang))
var language = i18n.normalizeLanguage(i18n.languageFrom(t.locale_data.messages[''].lang))
supportedLanguages.push(language)
var translator = new Jed(t)
translator.language = language