Skip to content

Commit 81f6f49

Browse files
committed
Replace jshint with eslint
1 parent ae7fd23 commit 81f6f49

File tree

7 files changed

+85
-105
lines changed

7 files changed

+85
-105
lines changed

.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"mocha": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"defaults"
9+
],
10+
"rules": {
11+
"no-console": 0,
12+
"no-trailing-spaces": "warn",
13+
"quotes": ["warn", "double"],
14+
"semi": "warn",
15+
"indent": ["warn", "tab"]
16+
}
17+
}

.jscsrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

bin/globalize-compiler.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,61 @@ var pkg = require( "../package.json" );
99
var bundle, cldr, extracts, extraOptions, input, locale, messages, opts, output, requiredOpts;
1010

1111
function help() {
12-
var out = [
13-
"Usage: globalize-compiler -l LOCALE [-m MESSAGES_FILE] -o DEST_FILE SRC_FILES...",
14-
"Example: globalize-compiler -l en -o app-en.js src/*.js",
15-
"",
16-
"Extracts formatters and parsers statically from the SRC_FILES and generates",
17-
"a precompiled bundle into DEST_FILE using LOCALE.",
18-
"",
19-
"General options:",
20-
" -h, --help # Print options and usage.",
21-
" -v, --version # Print the version number.",
22-
" -l, --locale LOCALE # Specify a LOCALE to use in compilation.",
23-
" -c, --cldr CLDR_FILE # Optional. All necessary CLDR data for given locale (JSON format).",
24-
" -m, --messages MESSAGES_FILE # Optional. Translation messages for given locale (JSON format).",
25-
" -o, --output DEST_FILE # Destination JS file, e.g., `app-en.js`.",
26-
""
27-
];
12+
var out = [
13+
"Usage: globalize-compiler -l LOCALE [-m MESSAGES_FILE] -o DEST_FILE SRC_FILES...",
14+
"Example: globalize-compiler -l en -o app-en.js src/*.js",
15+
"",
16+
"Extracts formatters and parsers statically from the SRC_FILES and generates",
17+
"a precompiled bundle into DEST_FILE using LOCALE.",
18+
"",
19+
"General options:",
20+
" -h, --help # Print options and usage.",
21+
" -v, --version # Print the version number.",
22+
" -l, --locale LOCALE # Specify a LOCALE to use in compilation.",
23+
" -c, --cldr CLDR_FILE # Optional. All necessary CLDR data for given locale (JSON format).",
24+
" -m, --messages MESSAGES_FILE # Optional. Translation messages for given locale (JSON format).",
25+
" -o, --output DEST_FILE # Destination JS file, e.g., `app-en.js`.",
26+
""
27+
];
2828

29-
return out.join( "\n" );
29+
return out.join( "\n" );
3030
}
3131

3232
opts = nopt( {
33-
help: Boolean,
34-
version: Boolean,
35-
locale: String,
36-
cldr: path,
37-
messages: path,
38-
output: path
33+
help: Boolean,
34+
version: Boolean,
35+
locale: String,
36+
cldr: path,
37+
messages: path,
38+
output: path
3939
}, {
40-
h: "--help",
41-
v: "--version",
42-
l: "--locale",
43-
c: "--cldr",
44-
m: "--messages",
45-
o: "--output"
40+
h: "--help",
41+
v: "--version",
42+
l: "--locale",
43+
c: "--cldr",
44+
m: "--messages",
45+
o: "--output"
4646
});
4747
requiredOpts = true;
4848

4949
if ( opts.version ) {
50-
return console.log( pkg.version );
50+
return console.log( pkg.version );
5151
}
5252

5353
if ( !opts.locale || !opts.output ) {
54-
requiredOpts = false;
54+
requiredOpts = false;
5555
}
5656

5757
extraOptions = Object.keys( opts ).filter(function( option ) {
58-
return !/help|version|locale|cldr|messages|output|argv/.test( option );
58+
return !/help|version|locale|cldr|messages|output|argv/.test( option );
5959
});
6060

6161
if ( extraOptions.length ) {
62-
console.log( "Invalid options:", extraOptions.join( ", " ), "\n" );
62+
console.log( "Invalid options:", extraOptions.join( ", " ), "\n" );
6363
}
6464

6565
if ( opts.help || !requiredOpts || extraOptions.length ) {
66-
return console.log( help() );
66+
return console.log( help() );
6767
}
6868

6969
input = opts.argv.remain;
@@ -76,14 +76,14 @@ cldr = cldr ? JSON.parse( fs.readFileSync( cldr ) ) : null;
7676
messages = messages ? JSON.parse( fs.readFileSync( messages ) ) : null;
7777

7878
extracts = input.map(function( input ) {
79-
return GlobalizeCompiler.extract( input );
79+
return GlobalizeCompiler.extract( input );
8080
});
8181

8282
bundle = GlobalizeCompiler.compileExtracts({
83-
defaultLocale: locale,
84-
cldr: cldr,
85-
messages: messages,
86-
extracts: extracts
83+
defaultLocale: locale,
84+
cldr: cldr,
85+
messages: messages,
86+
extracts: extracts
8787
});
8888

8989
fs.writeFileSync( output, bundle );

lib/compile.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var COMPILED_ORDER, DEPENDENCIES, DEPENDENCIES_VARS, fnPlaceholder, fnPlaceholderRe,
2-
regexpPlaceholder, regexpPlaceholderRe, slice, template, undefinedPlaceholder,
2+
regexpPlaceholder, regexpPlaceholderRe, template, undefinedPlaceholder,
33
undefinedPlaceholderRe,
44
extend = require( "util" )._extend,
55
fs = require( "fs" );
@@ -31,7 +31,7 @@ DEPENDENCIES = {
3131
numberParser: { number: true },
3232
pluralGenerator: { plural: true },
3333
relativeTimeFormatter: { number: true, plural: true, "relative-time": true },
34-
unitFormatter: { number: true, plural: true, unit: true },
34+
unitFormatter: { number: true, plural: true, unit: true }
3535
};
3636

3737
DEPENDENCIES_VARS = {
@@ -89,7 +89,6 @@ DEPENDENCIES_VARS = {
8989
}
9090
};
9191

92-
slice = [].slice;
9392
template = fs.readFileSync( __dirname + "/compile.template" ).toString( "utf-8" );
9493

9594
function functionName( fn ) {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"globalize-compiler": "./bin/globalize-compiler"
1414
},
1515
"scripts": {
16-
"test": "jshint index.js lib/**/*.js test/*.js && mocha"
16+
"test": "eslint --ignore-path .gitignore --ext .js index.js lib test bin && mocha"
1717
},
1818
"repository": {
1919
"type": "git",
@@ -41,6 +41,8 @@
4141
"babel": "^5.6.14",
4242
"chai": "1.10.x",
4343
"cldr-data": ">=25",
44+
"eslint": "^3.19.0",
45+
"eslint-config-defaults": "^9.0.0",
4446
"globalize": ">=1.3.0-a <2.0.0",
4547
"jshint": "2.6.x",
4648
"mocha": "2.1.0"

test/.jshintrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/index.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ var expect = require("chai").expect;
44
var globalizeCompiler = require("../index");
55

66
var fixtures = {
7-
//babel: esprima.parse(babel.transform(fs.readFileSync(__dirname + "/fixtures/es6.js")).code),
8-
basic: esprima.parse(fs.readFileSync(__dirname + "/fixtures/basic.js"))
7+
//babel: esprima.parse(babel.transform(fs.readFileSync(__dirname + "/fixtures/es6.js")).code),
8+
basic: esprima.parse(fs.readFileSync(__dirname + "/fixtures/basic.js"))
99
};
1010

1111
describe("Extract Formatters & Parsers", function() {
12-
var compiledString, extract;
12+
var compiledString, extract;
1313

14-
it("should extract formatters and parsers from basic code", function() {
15-
extract = globalizeCompiler.extract(fixtures.basic);
16-
expect(extract).to.be.a("function");
17-
});
14+
it("should extract formatters and parsers from basic code", function() {
15+
extract = globalizeCompiler.extract(fixtures.basic);
16+
expect(extract).to.be.a("function");
17+
});
1818

19-
it("should compile extracts from basic code", function() {
20-
compiledString = globalizeCompiler.compileExtracts({
21-
defaultLocale: "en",
22-
messages: {
23-
en: {
24-
like: "Foo"
25-
}
26-
},
27-
extracts: extract
28-
});
19+
it("should compile extracts from basic code", function() {
20+
compiledString = globalizeCompiler.compileExtracts({
21+
defaultLocale: "en",
22+
messages: {
23+
en: {
24+
like: "Foo"
25+
}
26+
},
27+
extracts: extract
28+
});
2929

30-
expect(compiledString).to.be.a("string");
31-
});
30+
expect(compiledString).to.be.a("string");
31+
});
3232

33-
describe("compile.js", function() {
34-
it("should handle runtimeArgs regexps", function() {
35-
expect(compiledString).to.have.string("numberParserFn([{\".\":\".\",\",\":\",\",\"%\":\"%\",\"+\":\"+\",\"-\":\"-\",\"E\":\"E\",\"‰\":\"‰\"},,{\"infinity\":/^∞/,\"nan\":/^NaN/,\"negativePrefix\":/^-/,\"negativeSuffix\":/^/,\"number\":/^((\\d{1,3}(,\\d{3})+|\\d+))?(\\.\\d+)?/,\"prefix\":/^/,\"suffix\":/^/}]);");
36-
});
37-
});
33+
describe("compile.js", function() {
34+
it("should handle runtimeArgs regexps", function() {
35+
expect(compiledString).to.have.string("numberParserFn([{\".\":\".\",\",\":\",\",\"%\":\"%\",\"+\":\"+\",\"-\":\"-\",\"E\":\"E\",\"‰\":\"‰\"},,{\"infinity\":/^∞/,\"nan\":/^NaN/,\"negativePrefix\":/^-/,\"negativeSuffix\":/^/,\"number\":/^((\\d{1,3}(,\\d{3})+|\\d+))?(\\.\\d+)?/,\"prefix\":/^/,\"suffix\":/^/}]);");
36+
});
37+
});
3838

3939
});

0 commit comments

Comments
 (0)