Skip to content

Commit 4ef4dac

Browse files
rafaelhzkunalkapadia
authored andcommitted
Fix .eslintrc to use 2 spaces as indent style (#22)
* Fix the .editorconfig to use TAB as indent style The eslint config for indent style is defined as Tab, but in the .editorconfig file it was space * Update eslint and editorconfig to use spaces instead tab * Replace all tabs with spaces
1 parent 4271999 commit 4ef4dac

18 files changed

+410
-410
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ trim_trailing_whitespace = true
1010
insert_final_newline = true
1111

1212
[*.md]
13-
trim_trailing_whitespace = false
13+
trim_trailing_whitespace = false

.eslintrc

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
{
2-
"rules": {
3-
"indent": [
4-
2,
5-
"tab",
6-
{
7-
"SwitchCase": 1
8-
}
9-
],
10-
"space-before-function-paren": [
11-
2,
12-
{
13-
"anonymous": "always",
14-
"named": "never"
15-
}
16-
],
17-
"no-use-before-define": [
18-
2,
19-
"nofunc"
20-
],
21-
// TODO: turn on later
22-
"comma-dangle": [
23-
0
24-
]
25-
},
26-
"env": {
27-
"node": true,
28-
"mocha": true
29-
},
30-
"extends": [
31-
"eslint:recommended",
32-
"airbnb/base"
33-
]
34-
}
2+
"rules": {
3+
"indent": [
4+
2,
5+
2,
6+
{
7+
"SwitchCase": 1
8+
}
9+
],
10+
"space-before-function-paren": [
11+
2,
12+
{
13+
"anonymous": "always",
14+
"named": "never"
15+
}
16+
],
17+
"no-use-before-define": [
18+
2,
19+
"nofunc"
20+
],
21+
// TODO: turn on later
22+
"comma-dangle": [
23+
0
24+
]
25+
},
26+
"env": {
27+
"node": true,
28+
"mocha": true
29+
},
30+
"extends": [
31+
"eslint:recommended",
32+
"airbnb/base"
33+
]
34+
}

config/env/development.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
env: 'development',
3-
db: 'mongodb://localhost/express-mongoose-es6-rest-api-development',
4-
port: 3000
2+
env: 'development',
3+
db: 'mongodb://localhost/express-mongoose-es6-rest-api-development',
4+
port: 3000
55
};

config/env/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const env = process.env.NODE_ENV || 'development';
55
const config = require(`./${env}`);
66

77
const defaults = {
8-
root: path.join(__dirname, '/..')
8+
root: path.join(__dirname, '/..')
99
};
1010

1111
_.assign(config, defaults);

config/env/production.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
env: 'production',
3-
db: 'mongodb://localhost/express-mongoose-es6-rest-api-production',
4-
port: 3000
2+
env: 'production',
3+
db: 'mongodb://localhost/express-mongoose-es6-rest-api-production',
4+
port: 3000
55
};

config/env/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
env: 'test',
3-
db: 'mongodb://localhost/express-mongoose-es6-rest-api-test',
4-
port: 3000
2+
env: 'test',
3+
db: 'mongodb://localhost/express-mongoose-es6-rest-api-test',
4+
port: 3000
55
};

config/express.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import APIError from '../server/helpers/APIError';
1717
const app = express();
1818

1919
if (config.env === 'development') {
20-
app.use(logger('dev'));
20+
app.use(logger('dev'));
2121
}
2222

2323
// parse body params and attache them to req.body
@@ -36,52 +36,52 @@ app.use(cors());
3636

3737
// enable detailed API logging in dev env
3838
if (config.env === 'development') {
39-
expressWinston.requestWhitelist.push('body');
40-
expressWinston.responseWhitelist.push('body');
41-
app.use(expressWinston.logger({
42-
winstonInstance,
43-
meta: true, // optional: log meta data about request (defaults to true)
44-
msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
45-
colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
46-
}));
39+
expressWinston.requestWhitelist.push('body');
40+
expressWinston.responseWhitelist.push('body');
41+
app.use(expressWinston.logger({
42+
winstonInstance,
43+
meta: true, // optional: log meta data about request (defaults to true)
44+
msg: 'HTTP {{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms',
45+
colorStatus: true // Color the status code (default green, 3XX cyan, 4XX yellow, 5XX red).
46+
}));
4747
}
4848

4949
// mount all routes on /api path
5050
app.use('/api', routes);
5151

5252
// if error is not an instanceOf APIError, convert it.
5353
app.use((err, req, res, next) => {
54-
if (err instanceof expressValidation.ValidationError) {
55-
// validation error contains errors which is an array of error each containing message[]
56-
const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
57-
const error = new APIError(unifiedErrorMessage, err.status, true);
58-
return next(error);
59-
} else if (!(err instanceof APIError)) {
60-
const apiError = new APIError(err.message, err.status, err.isPublic);
61-
return next(apiError);
62-
}
63-
return next(err);
54+
if (err instanceof expressValidation.ValidationError) {
55+
// validation error contains errors which is an array of error each containing message[]
56+
const unifiedErrorMessage = err.errors.map(error => error.messages.join('. ')).join(' and ');
57+
const error = new APIError(unifiedErrorMessage, err.status, true);
58+
return next(error);
59+
} else if (!(err instanceof APIError)) {
60+
const apiError = new APIError(err.message, err.status, err.isPublic);
61+
return next(apiError);
62+
}
63+
return next(err);
6464
});
6565

6666
// catch 404 and forward to error handler
6767
app.use((req, res, next) => {
68-
const err = new APIError('API not found', httpStatus.NOT_FOUND);
69-
return next(err);
68+
const err = new APIError('API not found', httpStatus.NOT_FOUND);
69+
return next(err);
7070
});
7171

7272
// log error in winston transports except when executing test suite
7373
if (config.env !== 'test') {
74-
app.use(expressWinston.errorLogger({
75-
winstonInstance
76-
}));
74+
app.use(expressWinston.errorLogger({
75+
winstonInstance
76+
}));
7777
}
7878

7979
// error handler, send stacktrace only during development
8080
app.use((err, req, res, next) => // eslint-disable-line no-unused-vars
81-
res.status(err.status).json({
82-
message: err.isPublic ? err.message : httpStatus[err.status],
83-
stack: config.env === 'development' ? err.stack : {}
84-
})
81+
res.status(err.status).json({
82+
message: err.isPublic ? err.message : httpStatus[err.status],
83+
stack: config.env === 'development' ? err.stack : {}
84+
})
8585
);
8686

8787
export default app;

config/param-validation.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import Joi from 'joi';
22

33
export default {
4-
// POST /api/users
5-
createUser: {
6-
body: {
7-
username: Joi.string().required(),
8-
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
9-
}
10-
},
4+
// POST /api/users
5+
createUser: {
6+
body: {
7+
username: Joi.string().required(),
8+
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
9+
}
10+
},
1111

12-
// UPDATE /api/users/:userId
13-
updateUser: {
14-
body: {
15-
username: Joi.string().required(),
16-
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
17-
},
18-
params: {
19-
userId: Joi.string().hex().required()
20-
}
21-
}
12+
// UPDATE /api/users/:userId
13+
updateUser: {
14+
body: {
15+
username: Joi.string().required(),
16+
mobileNumber: Joi.string().regex(/^[1-9][0-9]{9}$/).required()
17+
},
18+
params: {
19+
userId: Joi.string().hex().required()
20+
}
21+
}
2222
};

config/winston.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import winston from 'winston';
22

33
const logger = new (winston.Logger)({
4-
transports: [
5-
new (winston.transports.Console)({
6-
json: true,
7-
colorize: true
8-
})
9-
]
4+
transports: [
5+
new (winston.transports.Console)({
6+
json: true,
7+
colorize: true
8+
})
9+
]
1010
});
1111

1212
export default logger;

0 commit comments

Comments
 (0)