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

Lint monorepo only #1123

Merged
merged 25 commits into from
May 7, 2018
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
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"devDependencies": {
"assert": "~1.3.0",
"babel-eslint": "^6.1.2",
"chalk": "^2.4.1",
"eslint": "^3.12.2",
"eslint-plugin-babel": "^4.0.0",
"eslint-plugin-react": "^6.8.0",
Expand All @@ -15,7 +16,8 @@
"mocha": "~2.4.5",
"pre-commit": "~1.1.2",
"redux-saga": "^0.14.3",
"shelljs": "^0.7.7"
"shelljs": "^0.7.7",
"strapi-lint": "file:packages/strapi-lint"
},
"scripts": {
"clean": "npm run removesymlinkdependencies && rm -rf package-lock.json && rm -rf packages/*/package-lock.json",
Expand All @@ -25,8 +27,10 @@
"createsymlinkdependencies": "node ./scripts/createSymlinkDependencies.js",
"removesymlinkdependencies": "node ./scripts/removeSymlinkDependencies.js",
"setup:build": "npm run setup --build",
"setup": "npm run clean:all && npm install && node ./scripts/setup.js && npm run clean",
"test": "make test"
"setup": "npm run clean:all && npm install ./packages/strapi-lint --save-dev && npm install && node ./scripts/setup.js && npm run clean",
"lint": "node ./scripts/lint.js",
"test": "npm run lint",
"prettier": "node ./packages/strapi-lint/lib/internals/prettier/index.js"
},
"author": {
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/strapi-admin/admin/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-disable */
import './public-path';
import 'babel-polyfill';

/* eslint-disable no-console */
// Import all the third party stuff
import { Provider } from 'react-redux';
import React from 'react';
Expand Down
5 changes: 1 addition & 4 deletions packages/strapi-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
"prestart": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development PORT=4000 IS_ADMIN=true node ./node_modules/strapi-helper-plugin/lib/internals/scripts/loadAdminConfigurations.js",
"start": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development PORT=4000 IS_ADMIN=true node ./node_modules/strapi-helper-plugin/lib/server",
"generate": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/plop --plopfile ./node_modules/strapi-helper-plugin/lib/internals/generators/index.js",
"lint:front": "node ./node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern '/admin/build/' --config ./node_modules/strapi-lint/lib/internals/eslint/front/.eslintrc.json admin",
"lint:back": "node ./node_modules/strapi-lint/node_modules/.bin/eslint --ignore-path .gitignore --ignore-pattern '/admin/build/' --config ./node_modules/strapi-lint/lib/internals/eslint/back/.eslintrc.json controllers config services",
"prettier": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/prettier --single-quote --trailing-comma es5 --write \"{admin,__{tests,mocks}__}/**/*.js\"",
"test": "npm run lint:front && npm run lint:back",
"test": "echo \"Error: no test specified\"",
"prepublishOnly": "npm run build",
"setup": "node ./scripts/setup.js",
"presetup": "node ./scripts/preSetup.js"
Expand All @@ -34,7 +32,6 @@
"devDependencies": {
"sanitize.css": "^4.1.0",
"strapi-helper-plugin": "3.0.0-alpha.12",
"strapi-lint": "3.0.0-alpha.12",
"strapi-utils": "3.0.0-alpha.12"
},
"author": {
Expand Down
53 changes: 28 additions & 25 deletions packages/strapi-bookshelf/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ const _ = require('lodash');
const bookshelf = require('bookshelf');
const pluralize = require('pluralize');

// Local helpers.
const utils = require('./utils/');

// Strapi helpers for models.
const utilsModels = require('strapi-utils').models;

// Local helpers.
const utils = require('./utils/');

const PIVOT_PREFIX = '_pivot_';
const GLOBALS = {};

/**
* Bookshelf hook
*/

/* eslint-disable no-unused-vars */
/* eslint-disable prefer-template */
/* eslint-disable no-case-declarations */
module.exports = function(strapi) {
const hook = {
/**
Expand Down Expand Up @@ -86,18 +89,18 @@ module.exports = function(strapi) {

// Register the final model for Bookshelf.
const loadedModel = _.assign({
tableName: definition.collectionName,
hasTimestamps: _.get(definition, 'options.timestamps') === true,
idAttribute: _.get(definition, 'options.idAttribute', 'id'),
associations: [],
defaults: Object.keys(definition.attributes).reduce((acc, current) => {
if (definition.attributes[current].type && definition.attributes[current].default) {
acc[current] = definition.attributes[current].default;
}
tableName: definition.collectionName,
hasTimestamps: _.get(definition, 'options.timestamps') === true,
idAttribute: _.get(definition, 'options.idAttribute', 'id'),
associations: [],
defaults: Object.keys(definition.attributes).reduce((acc, current) => {
if (definition.attributes[current].type && definition.attributes[current].default) {
acc[current] = definition.attributes[current].default;
}

return acc;
}, {})
}, definition.options);
return acc;
}, {})
}, definition.options);

if (_.isString(_.get(connection, 'options.pivot_prefix'))) {
loadedModel.toJSON = function(options = {}) {
Expand Down Expand Up @@ -201,7 +204,7 @@ module.exports = function(strapi) {
});

return attrs;
}
};

// Initialize lifecycle callbacks.
loadedModel.initialize = function() {
Expand Down Expand Up @@ -497,7 +500,7 @@ module.exports = function(strapi) {
.query(qb => {
qb.where(_.get(model, `attributes.${details.via}.filter`, 'field'), name);
});
}
};
break;
}
case 'morphMany': {
Expand All @@ -513,7 +516,7 @@ module.exports = function(strapi) {
.query(qb => {
qb.where(_.get(collection, `attributes.${details.via}.filter`, 'field'), name);
});
}
};
break;
}
case 'belongsToMorph':
Expand Down Expand Up @@ -605,7 +608,7 @@ module.exports = function(strapi) {
cb();
},

getQueryParams: (value, type, key) => {
getQueryParams: (value, type, key) => {
const result = {};

switch (type) {
Expand Down Expand Up @@ -821,7 +824,7 @@ module.exports = function(strapi) {
strapi.plugins[obj.source].models[obj.ref]:
strapi.models[obj.ref];

virtualFields.push(this.addRelationMorph(details.model || details.collection, {
virtualFields.push(this.addRelationMorph(details.model || details.collection, {
id: response[this.primaryKey],
alias: association.alias,
ref: model.collectionName,
Expand All @@ -840,7 +843,7 @@ module.exports = function(strapi) {
}

return value;
})
});
}

if (association.type === 'model') {
Expand Down Expand Up @@ -987,11 +990,11 @@ module.exports = function(strapi) {
}

return await Model.morph.forge({
[`${Model.collectionName}_id`]: params.id,
[`${params.alias}_id`]: params.refId,
[`${params.alias}_type`]: params.ref,
field: params.field
})
[`${Model.collectionName}_id`]: params.id,
[`${params.alias}_id`]: params.refId,
[`${params.alias}_type`]: params.ref,
field: params.field
})
.save();
},

Expand Down
8 changes: 4 additions & 4 deletions packages/strapi-bookshelf/lib/utils/connectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = (scope, success, error) => {

success();
})
.catch(() => {
logger.warn('Database connection has failed! Make sure your database is running.');
error();
});
.catch(() => {
logger.warn('Database connection has failed! Make sure your database is running.');
error();
});
};
2 changes: 1 addition & 1 deletion packages/strapi-bookshelf/lib/utils/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const _ = require('lodash');

// Strapi helper for GraphQL.
const helpers = require('strapi/lib/configuration/hooks/graphql/helpers/');
const helpers = require('strapi/lib/configuration/hooks/graphql/helpers/'); // eslint-disable-line import/no-unresolved
const utils = require('./');

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/strapi-bookshelf/lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const _ = require('lodash');
/**
* Utils functions for BookShelf
*/

/* eslint-disable prefer-template */
module.exports = {

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/strapi-ejs/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const path = require('path');

// Externals
const co = require('co');
const render = require('koa-ejs');
const _ = require('lodash');
const render = require('koa-ejs'); // eslint-disable-line import/no-unresolved

/**
* EJS hook
Expand Down
4 changes: 2 additions & 2 deletions packages/strapi-generate-api/lib/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const pluralize = require('pluralize');

// Fetch stub attribute template on initial load.
const attributeTemplate = fs.readFileSync(path.resolve(__dirname, '..', 'templates', 'attribute.template'), 'utf8');

/* eslint-disable prefer-template */
/**
* This `before` function is run before generating targets.
* Validate, configure defaults, get extra dependencies, etc.
Expand Down Expand Up @@ -92,7 +92,7 @@ module.exports = (scope, cb) => {
return _.has(attribute, 'params.type') ? attribute : undefined;
}
});

scope.attributes = _.compact(scope.attributes);

// Handle invalid action arguments.
Expand Down
2 changes: 1 addition & 1 deletion packages/strapi-generate-controller/lib/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Public node modules.
const _ = require('lodash');

/* eslint-disable prefer-template */
/**
* This `before` function is run before generating targets.
* Validate, configure defaults, get extra dependencies, etc.
Expand Down
1 change: 1 addition & 0 deletions packages/strapi-generate-model/lib/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const pluralize = require('pluralize');

// Fetch stub attribute template on initial load.
const attributeTemplate = fs.readFileSync(path.resolve(__dirname, '..', 'templates', 'attribute.template'), 'utf8');
/* eslint-disable prefer-template */

/**
* This `before` function is run before generating targets.
Expand Down
4 changes: 3 additions & 1 deletion packages/strapi-generate-new/lib/after.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const logger = require('strapi-utils').logger;
* @param {Function} cb
*/

/* eslint-disable no-console */
/* eslint-disable prefer-template */
module.exports = (scope, cb) => {
const packageJSON = require(path.resolve(scope.rootPath, 'package.json'));
const strapiRootPath = path.resolve(scope.strapiRoot, '..');
// const strapiRootPath = path.resolve(scope.strapiRoot, '..');

process.chdir(scope.rootPath);

Expand Down
Loading