Permalink
Browse files

Use ESLint instead of xo

  • Loading branch information...
1 parent b7378d0 commit 5c24f33c2827bf5670ca2ec2eaa17bcfd47e4546 @Aurelsicoko Aurelsicoko committed Jan 4, 2017
View
@@ -0,0 +1,4 @@
+packages/strapi-generate-new/files/public/**
+packages/strapi-generate-admin/files/admin/public/**
+website/
+**/node_modules/**
View
@@ -0,0 +1,31 @@
+{
+ "parser": "babel-eslint",
+ "extends": "eslint:recommended",
+ "plugins": [
+ "react",
+ "jsx-a11y"
+ ],
+ "env": {
+ "commonjs": true,
+ "es6": true,
+ "node": true,
+ "mocha": true
+ },
+ "parserOptions": {
+ "ecmaFeatures": {
+ "experimentalObjectRestSpread": true,
+ "jsx": true
+ },
+ "sourceType": "module"
+ },
+ "globals": {
+ "strapi": true
+ },
+ "rules": {
+ "indent": ["error", 2, { "SwitchCase": 1 }],
+ "linebreak-style": ["error", "unix"],
+ "no-console": 0,
+ "quotes": ["error", "single"],
+ "semi": ["error", "always"]
+ }
+}
View
@@ -5,7 +5,7 @@ export NODE_ENV = test
.PHONY: test
lint:
- ./node_modules/.bin/xo
+ ./node_modules/.bin/eslint **/*.js
test: lint
./scripts/test.sh
View
@@ -3,63 +3,31 @@
"version": "3.0.0-alpha.1",
"devDependencies": {
"assert": "~1.3.0",
+ "babel-eslint": "^6.1.2",
"coveralls": "~2.11.9",
+ "eslint": "^3.12.2",
+ "eslint-config-airbnb": "^13.0.0",
+ "eslint-plugin-import": "^2.2.0",
+ "eslint-plugin-jsx-a11y": "^3.0.2",
+ "eslint-plugin-react": "^6.8.0",
"istanbul": "~0.4.2",
+ "lerna": "2.0.0-beta.30",
"mocha": "~2.4.5",
"mocha-lcov-reporter": "~1.2.0",
- "pre-commit": "~1.1.2",
- "xo": "~0.13.0",
- "lerna": "2.0.0-beta.30"
- },
- "xo": {
- "space": true,
- "esnext": true,
- "envs": [
- "mocha",
- "node"
- ],
- "globals": [
- "strapi"
- ],
- "ignore": [
- "packages/strapi-generate-new/files/public/**",
- "packages/strapi-generate-admin/files/admin/public/**",
- "website/**"
- ],
- "rules": {
- "array-callback-return": 0,
- "brace-style": 0,
- "camelcase": 0,
- "default-case": 0,
- "dot-notation": 0,
- "no-case-declarations": 0,
- "no-else-return": 0,
- "no-eval": 0,
- "no-implicit-coercion": 0,
- "no-lonely-if": 0,
- "no-negated-condition": 0,
- "no-throw-literal": 0,
- "no-unused-expressions": 0,
- "no-unused-vars": 0,
- "padded-blocks": 0,
- "prefer-template": 0,
- "quote-props": 0,
- "space-infix-ops": 0,
- "strict": 0
- }
+ "pre-commit": "~1.1.2"
},
"scripts": {
"test": "make test",
"setup": "make setup"
},
"author": {
"email": "hi@strapi.io",
- "name": "Strapi team",
+ "name": "Strapi Solutions",
"url": "http://strapi.io"
},
"maintainers": [
{
- "name": "Strapi team",
+ "name": "Strapi Solutions",
"email": "hi@strapi.io",
"url": "http://strapi.io"
}
@@ -158,7 +158,7 @@ module.exports = function (strapi) {
}
switch (verbose) {
- case 'hasOne':
+ case 'hasOne': {
const FK = _.findKey(strapi.models[details.model].attributes, details => {
if (details.hasOwnProperty('model') && details.model === model && details.hasOwnProperty('via') && details.via === name) {
return details;
@@ -169,20 +169,20 @@ module.exports = function (strapi) {
return this.hasOne(global[_.capitalize(details.model)], FK);
};
break;
-
- case 'hasMany':
+ }
+ case 'hasMany': {
loadedModel[name] = () => {
return this.hasMany(global[_.capitalize(details.collection)], details.via);
};
break;
-
- case 'belongsTo':
+ }
+ case 'belongsTo': {
loadedModel[name] = () => {
return this.belongsTo(global[_.capitalize(details.model)], name);
};
break;
-
- case 'belongsToMany':
+ }
+ case 'belongsToMany': {
const tableName = _.map(_.sortBy([strapi.models[details.collection].attributes[details.via], details], 'collection'), table => {
return _.snakeCase(pluralize.plural(table.collection) + ' ' + pluralize.plural(table.via));
}).join('__');
@@ -207,9 +207,10 @@ module.exports = function (strapi) {
return this.belongsToMany(global[_.capitalize(details.collection)], tableName, relationship.attribute + '_' + relationship.column, details.attribute + '_' + details.column);
};
break;
-
- default:
+ }
+ default: {
break;
+ }
}
done();
@@ -108,7 +108,7 @@ module.exports = {
* @return {Object}
*/
- create: (collectionIdentity, rootValue, args) => {
+ create: (collectionIdentity, rootValue) => {
return strapi.services[collectionIdentity.toLowerCase()]
.add(rootValue.context.request.body)
.then(data => _.isFunction(_.get(data, 'toJSON')) ? data.toJSON() : data);
@@ -10,8 +10,12 @@ const path = require('path');
module.exports = {
index: async ctx => {
- // Send the HTML file with injected scripts
- ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
+ try {
+ // Send the HTML file with injected scripts
+ ctx.body = strapi.admin.services.admin.generateAdminIndexFile();
+ } catch (err) {
+ ctx.body = err;
+ }
},
file: async ctx => {
@@ -6,7 +6,6 @@
// Node.js core.
const fs = require('fs');
-const path = require('path');
// Public node modules.
const _ = require('lodash');
@@ -4,10 +4,6 @@
* Module dependencies
*/
-// Node.js core.
-const fs = require('fs');
-const path = require('path');
-
// Public node modules.
const _ = require('lodash');
@@ -19,10 +15,6 @@ const _ = require('lodash');
module.exports = scope => {
const cliPkg = scope.strapiPackageJSON || {};
- // To determine the Strapi dependency to inject
- // in the newly created `package.json`.
- const frameworkPkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'strapi', 'package.json'))) || {};
-
// Finally, return the JSON.
return _.merge(scope.appPackageJSON || {}, {
'name': scope.name,
@@ -36,7 +36,6 @@ module.exports = (scope, cb) => {
// Use configured module name for this `generatorType` if applicable.
const module = 'strapi-generate-' + scope.generatorType;
let generator;
- let requireError;
function throwIfModuleNotFoundError(error, module) {
const isModuleNotFoundError = error && error.code === 'MODULE_NOT_FOUND' && error.message.match(new RegExp(module));
@@ -52,7 +51,7 @@ module.exports = (scope, cb) => {
try {
generator = require('../../' + module);
} catch (error) {
- requireError = throwIfModuleNotFoundError(error, module);
+ throwIfModuleNotFoundError(error, module);
}
if (!generator) {
@@ -8,7 +8,6 @@
const _ = require('lodash');
const mongoose = require('mongoose');
const mongooseUtils = require('mongoose/lib/utils');
-const pluralize = require('pluralize');
// Local helpers.
const utils = require('./utils/');
@@ -4,9 +4,6 @@
* Module dependencies
*/
-// Public node modules.
-const _ = require('lodash');
-
module.exports = mongoose => {
require('mongoose-double')(mongoose);
require('mongoose-float').loadType(mongoose);
@@ -55,7 +55,6 @@ module.exports = {
const ORM = this.getORM(collectionIdentity);
try {
- const GraphQLFunctions = require(path.resolve(strapi.config.appPath, 'node_modules', 'strapi-' + ORM, 'lib', 'utils'));
const ORMFunctions = require(path.resolve(strapi.config.appPath, 'node_modules', 'strapi-' + ORM, 'lib', 'utils'));
if (!_.isUndefined(ORMFunctions)) {
@@ -74,7 +73,6 @@ module.exports = {
*/
getNature: (association, key, models) => {
- const strapi = _.isUndefined(global['strapi']) && !_.isUndefined(models) ? _.set({}, 'models', models) : global['strapi'];
const types = {
current: '',
other: ''
@@ -9,9 +9,6 @@
// Node.js core.
const REPL = require('repl');
-// Public node modules.
-const _ = require('lodash');
-
// Local Strapi dependencies.
const strapi = require('../lib/');
@@ -122,7 +122,9 @@ try {
cmd.description(info.description);
cmd.action(require('./strapi-generate'));
});
-} catch (err) {}
+} catch (err) {
+ logger.error(err);
+}
// `$ strapi migrate:make`
cmd = program.command('migrate:make');
@@ -10,7 +10,6 @@ const http = require('http');
const EventEmitter = require('events').EventEmitter;
// Local dependencies.
-const _ = require('lodash');
const Koa = require('koa');
const mixinAfter = require('./private/after');
@@ -16,7 +16,7 @@ const responses = require('./responses/index');
const createResponses = ctx => {
return _.merge(
responses,
- _.mapValues(_.omit(Boom, ['wrap', 'create']), (fn, name) => (...rest) => {
+ _.mapValues(_.omit(Boom, ['wrap', 'create']), (fn) => (...rest) => {
ctx.body = fn(...rest);
})
);
@@ -59,7 +59,7 @@ module.exports = strapi => {
const endpoint = `${value.method} ${value.path}`;
try {
- const {route, policies, action, validate} = routerChecker(value, endpoint);
+ const {policies, action, validate} = routerChecker(value, endpoint);
if (_.isUndefined(action) || !_.isFunction(action)) {
return strapi.log.warn('Ignored attempt to bind route `' + endpoint + '` to unknown controller/action.');
@@ -88,7 +88,7 @@ module.exports = strapi => {
const endpoint = `${value.method} ${value.path}`;
try {
- const {route, policies, action, validate} = routerChecker(value, endpoint);
+ const {policies, action, validate} = routerChecker(value, endpoint);
if (_.isUndefined(action) || !_.isFunction(action)) {
return strapi.log.warn('Ignored attempt to bind route `' + endpoint + '` to unknown controller/action.');
@@ -131,7 +131,7 @@ module.exports = strapi => {
const endpoint = `${value.method} ${value.path}`;
try {
- const {route, policies, action, validate} = routerChecker(value, endpoint, plugin);
+ const {policies, action, validate} = routerChecker(value, endpoint, plugin);
if (_.isUndefined(action) || !_.isFunction(action)) {
return strapi.log.warn('Ignored attempt to bind route `' + endpoint + '` to unknown controller/action.');
@@ -160,7 +160,7 @@ module.exports = strapi => {
const endpoint = `${value.method} ${value.path}`;
try {
- const {route, policies, action, validate} = routerChecker(value, endpoint, plugin);
+ const {policies, action, validate} = routerChecker(value, endpoint, plugin);
if (_.isUndefined(action) || !_.isFunction(action)) {
return strapi.log.warn('Ignored attempt to bind route `' + endpoint + '` to unknown controller/action.');
@@ -187,7 +187,7 @@ module.exports = strapi => {
// an ES6 literal string without parenthesis inside (aka function call).
const regex = /^\$\{[^()]*\}$/g;
- return _.mapValues(object, (value, key) => {
+ return _.mapValues(object, (value) => {
if (_.isPlainObject(value)) {
return templateConfigurations(value);
} else if (_.isString(value) && regex.test(value)) {
@@ -6,7 +6,6 @@
// Public node modules.
const _ = require('lodash');
-const async = require('async');
/**
* Expose the strategy to load
@@ -53,7 +53,7 @@ module.exports = function (configOverride, cb) {
initializeHooks: ['loadDictionary', (result, cb) => initializeHooks.apply(this, [cb])],
// Load hooks into memory.
loadHooks: ['initializeHooks', (result, cb) => loadHooks.apply(this, [cb])]
- }, (err, results) => {
+ }, (err) => {
if (err) {
console.log(err);
}
@@ -116,7 +116,7 @@ module.exports = function (configOverride, cb) {
const mapper = _.clone(this.config.hooks);
// Map (warning: we could have some order issues).
- _.assignWith(mapper, this.tree, (objValue, srcValue) => {
+ _.assignWith(mapper, this.tree, (objValue) => {
if (_.isPlainObject(objValue)) {
return true;
}
@@ -4,9 +4,6 @@
* Module dependencies
*/
-// Public node modules.
-const _ = require('lodash');
-
/**
* `strapi.prototype.initialize()`
*

0 comments on commit 5c24f33

Please sign in to comment.