Skip to content

Commit

Permalink
feat(config): Deprecate JSHint in favor of ESLint
Browse files Browse the repository at this point in the history
Add basic ESLint setup extending well-known Airbnb code style.

Fixes meanjs#1072, meanjs#1097
  • Loading branch information
feimosi committed Mar 15, 2016
1 parent 4e9ad81 commit d14d513
Show file tree
Hide file tree
Showing 76 changed files with 266 additions and 255 deletions.
37 changes: 0 additions & 37 deletions .eslintrc

This file was deleted.

72 changes: 72 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
module.exports = {
extends: [
'airbnb/legacy'
],
rules: {
camelcase: 0,
'comma-dangle': [2, 'never'],
'comma-spacing': [2, { before: false, after: true }],
'consistent-return': 0,
curly: 0,
'default-case': 0,
eqeqeq: [2, 'smart'],
'func-names': 0,
'guard-for-in': 2,
indent: [2, 2, { SwitchCase: 1 }],
'key-spacing': [2, { beforeColon: false, afterColon: true }],
'keyword-spacing': [2, { before: true, after: true }],
'max-len': 0,
'new-cap': [2, { newIsCapExceptions: ['acl.memoryBackend', 'acl'] }],
'no-bitwise': 0,
'no-caller': 2,
'no-else-return': 0,
'no-empty-class': 0,
'no-multi-spaces': 2,
'no-param-reassign': 0,
'no-shadow': 0,
'no-spaced-func': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-unneeded-ternary': 2,
'no-unreachable': 2,
'no-underscore-dangle': 0,
'no-unused-expressions': 0,
'no-unused-vars': 0,
'no-use-before-define': [1, 'nofunc'],
'no-var': 0,
'object-curly-spacing': [2, 'always'],
'one-var': [0, 'never'],
'one-var-declaration-per-line': [2, 'always'],
'padded-blocks': 0,
'space-before-function-paren': 0,
'space-in-parens': [2, 'never'],
'spaced-comment': [2, 'always'],
strict: 0,
'quote-props': 0,
quotes: [1, 'single'],
'wrap-iife': [2, 'outside'],
'vars-on-top': 0
},
env: {
node: true,
browser: true,
jasmine: true,
mocha: true,
jquery: true
},
globals: {
angular: true,
by: true,
browser: true,
element: true,
inject: true,
io: true,
moment: true,
Modernizr: true,
Promise: true,
__TESTING__: true,
_: false,
ApplicationConfiguration: true
}
};
27 changes: 0 additions & 27 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion config/assets/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
css: [
// bower:css
'public/lib/bootstrap/dist/css/bootstrap.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css',
'public/lib/bootstrap/dist/css/bootstrap-theme.min.css'
// endbower
],
js: [
Expand Down
4 changes: 3 additions & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ var getGlobbedPaths = function (globPatterns, excludes) {
files = files.map(function (file) {
if (_.isArray(excludes)) {
for (var i in excludes) {
file = file.replace(excludes[i], '');
if (excludes.hasOwnProperty(i)) {
file = file.replace(excludes[i], '');
}
}
} else {
file = file.replace(excludes, '');
Expand Down
4 changes: 2 additions & 2 deletions config/env/cloud-foundry.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ module.exports = {
}
},
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
seed: process.env.MONGO_SEED === 'true',
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false',
seedUser: {
username: process.env.MONGO_SEED_USER_USERNAME || 'user',
provider: 'local',
Expand Down
2 changes: 1 addition & 1 deletion config/env/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
profileUpload: {
dest: './modules/users/client/img/profile/uploads/', // Profile upload destination path
limits: {
fileSize: 1*1024*1024 // Max file size in bytes (1 MB)
fileSize: 1 * 1024 * 1024 // Max file size in bytes (1 MB)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ module.exports = {
options: {
// Stream defaults to process.stdout
// Uncomment/comment to toggle the logging to a log on the file system
//stream: {
// stream: {
// directoryPath: process.cwd(),
// fileName: 'access.log',
// rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage
// active: false, // activate to use rotating logs
// active: false, // activate to use rotating logs
// fileName: 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used
// frequency: 'daily',
// verbose: false
// }
//}
// }
}
},
app: {
Expand Down Expand Up @@ -77,9 +77,9 @@ module.exports = {
},
livereload: true,
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
seed: process.env.MONGO_SEED === 'true',
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false',
seedUser: {
username: process.env.MONGO_SEED_USER_USERNAME || 'user',
provider: 'local',
Expand Down
2 changes: 1 addition & 1 deletion config/env/local.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Use it for your API keys, passwords, etc.

// WARNING: When using this example for multiple NODE_ENV's concurrently, make sure you update the 'db' settings appropriately.
// You do not want to accidentally overwrite/lose any data. For instance, if you create a file for 'test' and don't change the
// You do not want to accidentally overwrite/lose any data. For instance, if you create a file for 'test' and don't change the
// database name in the setting below, running the tests will drop all the data from the specified database.
//
// You may end up with a list of files, that will be used with their corresponding NODE_ENV:
Expand Down
8 changes: 4 additions & 4 deletions config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ module.exports = {
directoryPath: process.env.LOG_DIR_PATH || process.cwd(),
fileName: process.env.LOG_FILE || 'access.log',
rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage
active: process.env.LOG_ROTATING_ACTIVE === 'true' ? true : false, // activate to use rotating logs
active: process.env.LOG_ROTATING_ACTIVE === 'true', // activate to use rotating logs
fileName: process.env.LOG_ROTATING_FILE || 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used
frequency: process.env.LOG_ROTATING_FREQUENCY || 'daily',
verbose: process.env.LOG_ROTATING_VERBOSE === 'true' ? true : false
verbose: process.env.LOG_ROTATING_VERBOSE === 'true'
}
}
}
Expand Down Expand Up @@ -79,9 +79,9 @@ module.exports = {
}
},
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
seed: process.env.MONGO_SEED === 'true',
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false',
seedUser: {
username: process.env.MONGO_SEED_USER_USERNAME || 'user',
provider: 'local',
Expand Down
6 changes: 3 additions & 3 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
directoryPath: process.cwd(),
fileName: 'access.log',
rotatingLogs: { // for more info on rotating logs - https://github.com/holidayextras/file-stream-rotator#usage
active: false, // activate to use rotating logs
active: false, // activate to use rotating logs
fileName: 'access-%DATE%.log', // if rotating logs are active, this fileName setting will be used
frequency: 'daily',
verbose: false
Expand Down Expand Up @@ -77,9 +77,9 @@ module.exports = {
}
},
seedDB: {
seed: process.env.MONGO_SEED === 'true' ? true : false,
seed: process.env.MONGO_SEED === 'true',
options: {
logResults: process.env.MONGO_SEED_LOG_RESULTS === 'false' ? false : true,
logResults: process.env.MONGO_SEED_LOG_RESULTS !== 'false',
seedUser: {
username: process.env.MONGO_SEED_USER_USERNAME || 'user',
provider: 'local',
Expand Down
6 changes: 3 additions & 3 deletions config/lib/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ module.exports.start = function start(options) {
seedOptions.logResults = options.logResults;
}

if (_.has(options, 'seedUser')) {
seedOptions.seedUser = options.seedUser;
if (_.has(options, 'seedUser')) {
seedOptions.seedUser = options.seedUser;
}

if (_.has(options, 'seedAdmin')) {
Expand All @@ -134,7 +134,7 @@ module.exports.start = function start(options) {
var adminAccount = new User(seedOptions.seedAdmin);
var userAccount = new User(seedOptions.seedUser);

//If production only seed admin if it does not exist
// If production only seed admin if it does not exist
if (process.env.NODE_ENV === 'production') {
User.generateRandomPassphrase()
.then(seedTheUser(adminAccount))
Expand Down
19 changes: 4 additions & 15 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function (grunt) {
},
serverJS: {
files: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS),
tasks: ['jshint'],
tasks: ['eslint'],
options: {
livereload: true
}
Expand All @@ -47,7 +47,7 @@ module.exports = function (grunt) {
},
clientJS: {
files: defaultAssets.client.js,
tasks: ['jshint'],
tasks: ['eslint'],
options: {
livereload: true
}
Expand Down Expand Up @@ -91,17 +91,6 @@ module.exports = function (grunt) {
logConcurrentOutput: true
}
},
jshint: {
all: {
src: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e),
options: {
jshintrc: true,
node: true,
mocha: true,
jasmine: true
}
}
},
eslint: {
options: {},
target: _.union(defaultAssets.server.gruntConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e)
Expand Down Expand Up @@ -190,7 +179,7 @@ module.exports = function (grunt) {
coverage: true,
require: 'test.js',
coverageFolder: 'coverage/server',
reportFormats: ['cobertura','lcovonly'],
reportFormats: ['cobertura', 'lcovonly'],
check: {
lines: 40,
statements: 40
Expand Down Expand Up @@ -297,7 +286,7 @@ module.exports = function (grunt) {
});

// Lint CSS and JavaScript files.
grunt.registerTask('lint', ['sass', 'less', 'jshint', 'eslint', 'csslint']);
grunt.registerTask('lint', ['sass', 'less', 'eslint', 'csslint']);

// Lint project files and minify them into two production files.
grunt.registerTask('build', ['env:dev', 'lint', 'ngAnnotate', 'uglify', 'cssmin']);
Expand Down
Loading

0 comments on commit d14d513

Please sign in to comment.