Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jshint improvements #26

Merged
merged 5 commits into from
Apr 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
*.min.*
78 changes: 78 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{

// == Enforcing Options ===============================================
//
// These options tell JSHint to be more strict towards your code.

"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"es3" : false, // Adhere to ECMAScript 3 specification for legacy browsers like Internet Explorer 6/7/8.
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that should be false and forEach should be used instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of this is not which loop to use, but rather to enforce checking inside a for..in loop which is meant to make you check hasOwnProperty on keys of an object.

Also, forEach is actually not as fast as a regular for loop http://jsperf.com/for-vs-foreach/313.

"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"indent" : 4, // Specify indentation spacing
"latedef" : true, // Prohibit variable use before definition.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : "single", // Forces single quotes for strings

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't " the standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" is required for JSON, but javascript doesn't actually care

"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // Prevent declaring unused functions and variables.
"strict" : true, // Require `use strict` pragma in every file.
"maxparams" : 4, // Set the max number of formal parameters allowed per function
"maxlen" : 120, // Set the maximum line length

// == Relaxing Options ================================================
//
// These options allow you to suppress certain types of warnings. Use
// them only if you are absolutely positive that you know what you are
// doing.

"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // Tolerate use of `== null`.
"esnext" : false, // Allow ES.next specific features such as `const` and `let`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
"iterator" : false, // Allow usage of __iterator__ property.
"lastsemic" : false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : false, // Suppress warnings about comma-first coding style.
"loopfunc" : false, // Allow functions to be defined within loops.
"moz" : false, // Use Mozilla JavaScript extensions. Unless you develop specifically for the Firefox web browser you don't need this option.
"multistr" : false, // Tolerate multi-line strings.
"proto" : false, // Tolerate __proto__ property. This property is deprecated.
"scripturl" : false, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"validthis" : false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function.

// == Environments ====================================================
//
// These options pre-define global variables that are exposed by
// popular JavaScript libraries and runtime environments—such as
// browser or node.js.

"browser" : true, // Standard browser globals e.g. `window`, `document`.
"couch" : false, // Enable globals exposed by CouchDB.
"devel" : false, // Allow development statements e.g. `console.log();`.
"jquery" : false, // Enable globals exposed by jQuery JavaScript library.
"node" : true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"nonstandard" : false, // Define non-standard but widely adopted globals such as escape and unescape.
"wsh" : false, // Enable globals available when your code is running as a script for the Windows Script Host.

// == Global Variables ================================================
//
// These will be ignored by jsHint and will not throw warning caused by the
// debug or undef options

"globals": {
}
}
26 changes: 8 additions & 18 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');

module.exports = function(grunt) {
'use strict';

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
Expand All @@ -15,7 +16,7 @@ module.exports = function(grunt) {
},
},
uglify: {
my_target: {
target: {
files: [
{ src: [ 'dist/languages.js' ], dest: 'dist/min/languages.min.js', },
{ src: [ 'numbro.js' ], dest: 'dist/min/numbro.min.js', },
Expand Down Expand Up @@ -44,7 +45,8 @@ module.exports = function(grunt) {
createTag: false,
push: false,
globalReplace: true,
regExp: new RegExp('([\'|\"]?version[\'|\"]?[ ]*[:=][ ]*[\'|\"]?)(\\d+\\.\\d+\\.\\d+(-\\.\\d+)?(-\\d+)?)[\\d||A-a|.|-]*([\'|\"]?)')
regExp: new RegExp('([\'|\"]?version[\'|\"]?[ ]*[:=][ ]*[\'|\"]?)'+
'(\\d+\\.\\d+\\.\\d+(-\\.\\d+)?(-\\d+)?)[\\d||A-a|.|-]*([\'|\"]?)')
},
},
confirm: {
Expand All @@ -69,26 +71,14 @@ module.exports = function(grunt) {
all: ['tests/**/*.js'],
},
jshint: {
options: {
jshintrc : '.jshintrc'
},
all: [
'Gruntfile.js',
'numbro.js',
'languages/**/*.js'
],
options: {
'node': true,
'browser': true,
'curly': true,
'devel': false,
'eqeqeq': true,
'eqnull': true,
'newcap': true,
'noarg': true,
'onevar': true,
'undef': true,
'sub': true,
'strict': false,
'quotmark': 'single'
}
]
}
});

Expand Down
2 changes: 2 additions & 0 deletions languages/cs-CZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Anatoli Papirovski : https://github.com/apapirovski
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand Down
4 changes: 3 additions & 1 deletion languages/da-DK.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Michael Storgaard : https://github.com/mstorgaard
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '.',
Expand All @@ -15,7 +17,7 @@
billion: 'mia',
trillion: 'b'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Marco Krage : https://github.com/sinky
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -15,7 +17,7 @@
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/de-ch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Michael Piefel : https://github.com/piefel (based on work from Marco Krage : https://github.com/sinky)
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -15,7 +17,7 @@
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
2 changes: 2 additions & 0 deletions languages/en-GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Dan Ristic : https://github.com/dristic
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ',',
Expand Down
2 changes: 2 additions & 0 deletions languages/es-AR.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Hernan Garcia : https://github.com/hgarcia
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '.',
Expand Down
2 changes: 2 additions & 0 deletions languages/es-ES.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Hernan Garcia : https://github.com/hgarcia
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '.',
Expand Down
4 changes: 3 additions & 1 deletion languages/et-EE.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* from numbers with a space
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -18,7 +20,7 @@
billion: ' mld',
trillion: ' trl'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/fa-IR.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : neo13 : https://github.com/neo13
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '،',
Expand All @@ -15,7 +17,7 @@
billion: 'میلیارد',
trillion: 'تریلیون'
},
ordinal: function (number) {
ordinal: function () {
return 'ام';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/fi-FI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Sami Saada : https://github.com/samitheberber
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -15,7 +17,7 @@
billion: 'G',
trillion: 'T'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
2 changes: 2 additions & 0 deletions languages/fil-PH.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Michael Abadilla : https://github.com/mjmaix
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ',',
Expand Down
2 changes: 2 additions & 0 deletions languages/fr-CA.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Léo Renaud-Allaire : https://github.com/renaudleo
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand Down
2 changes: 2 additions & 0 deletions languages/fr-CH.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Adam Draper : https://github.com/adamwdraper
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '\'',
Expand Down
2 changes: 2 additions & 0 deletions languages/fr-FR.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Adam Draper : https://github.com/adamwdraper
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand Down
4 changes: 3 additions & 1 deletion languages/hu-HU.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Peter Bakondy : https://github.com/pbakondy
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -15,7 +17,7 @@
billion: 'Mrd', // milliárd
trillion: 'T' // trillió
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/it-IT.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Giacomo Trombi : http://cinquepunti.it
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: '.',
Expand All @@ -15,7 +17,7 @@
billion: 'b',
trillion: 't'
},
ordinal: function (number) {
ordinal: function () {
return 'º';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/ja-JP.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : teppeis : https://github.com/teppeis
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ',',
Expand All @@ -15,7 +17,7 @@
billion: '十億',
trillion: '兆'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
4 changes: 3 additions & 1 deletion languages/lv-LV.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* author : Lauris Bukšis-Haberkorns : https://github.com/Lafriks
*/
(function () {
'use strict';

var language = {
delimiters: {
thousands: ' ',
Expand All @@ -15,7 +17,7 @@
billion: ' mljrd.',
trillion: ' trilj.'
},
ordinal: function (number) {
ordinal: function () {
return '.';
},
currency: {
Expand Down
Loading