Merge pull request #14320 from strapi/chore/eslint

chore/eslint
This commit is contained in:
Alexandre BODIN 2022-09-08 14:45:12 +02:00 committed by GitHub
commit 59b83c5953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 133 additions and 112 deletions

View File

@ -26,14 +26,16 @@ module.exports = {
},
],
'prefer-destructuring': ['error', { AssignmentExpression: { array: false } }],
eqeqeq: 'warn',
'no-underscore-dangle': 'warn',
'no-use-before-define': 'warn',
'no-param-reassign': 'warn',
'no-underscore-dangle': 'off',
'no-use-before-define': 'off',
'no-continue': 'warn',
'no-process-exit': 'off',
'no-plusplus': 'warn',
'no-loop-func': 'warn',
'guard-for-in': 'warn',
'no-loop-func': 'off',
'no-param-reassign': [
'error',
{
props: false,
},
],
},
};

View File

@ -80,12 +80,10 @@ const buildAdmin = async () => {
new Error(
messages.errors.reduce((acc, error) => {
if (isObject(error)) {
acc += error.message;
} else {
acc += error.join('\n\n');
return acc + error.message;
}
return acc;
return acc + error.join('\n\n');
}, '')
)
);

View File

@ -426,7 +426,11 @@ describe('Role', () => {
const count = jest.fn(() => Promise.resolve(0));
let id = 1;
const create = jest.fn(({ data }) => ({ ...data, id: id++ }));
const create = jest.fn(({ data }) => {
const res = { ...data, id };
id += 1;
return res;
});
const values = jest.fn(() => actions);
const createMany = jest.fn();
const assignARoleToAll = jest.fn();

View File

@ -49,9 +49,10 @@ const unwrapDeep = (obj) => {
if (_.isPlainObject(v)) {
if ('$elemMatch' in v) {
v = v.$elemMatch; // removing this key
_.setWith(acc, key, unwrapDeep(v.$elemMatch));
} else {
_.setWith(acc, key, unwrapDeep(v));
}
_.setWith(acc, key, unwrapDeep(v));
} else if (_.isArray(v)) {
// prettier-ignore
_.setWith(acc, key, v.map(v => unwrapDeep(v)));

View File

@ -144,7 +144,7 @@ const cleanPermissionsInDatabase = async () => {
const total = await strapi.query('admin::permission').count();
const pageCount = Math.ceil(total / pageSize);
for (let page = 0; page < pageCount; page++) {
for (let page = 0; page < pageCount; page += 1) {
// 1. Find invalid permissions and collect their ID to delete them later
const results = await strapi
.query('admin::permission')

View File

@ -84,7 +84,7 @@ if (edition === 'EE') {
// Create users with the new role & create associated auth requests
const users = [];
for (let i = 0; i < localTestData.users.length; ++i) {
for (let i = 0; i < localTestData.users.length; i += 1) {
const userFixture = localTestData.users[i];
const userAttributes = {
...userFixture,

View File

@ -145,7 +145,7 @@ describe('Admin User CRUD (e2e)', () => {
};
};
for (let i = 0; i < 3; i++) {
for (let i = 0; i < 3; i += 1) {
const res = await rq({
url: '/admin/users',
method: 'POST',

View File

@ -12,7 +12,7 @@ const checkFieldsAreCorrectlyNested = (fields) => {
}
let failed = false;
for (let indexA = 0; indexA < fields.length; indexA++) {
for (let indexA = 0; indexA < fields.length; indexA += 1) {
failed = fields
.slice(indexA + 1)
.some(

View File

@ -69,7 +69,7 @@ module.exports = ({ strapi }) => ({
});
};
for (const key in model.attributes) {
for (const key of Object.keys(model.attributes)) {
const attribute = model.attributes[key];
if (attribute.type === 'component') {

View File

@ -130,7 +130,7 @@ module.exports = function createSchemaHandler(infos) {
}
// set new Attributes
for (const key in newAttributes) {
for (const key of Object.keys(newAttributes)) {
this.setAttribute(key, newAttributes[key]);
}

View File

@ -157,7 +157,7 @@ describe('Content Type Builder - Content types', () => {
const { uid } = createRes.body.data;
// create data
for (let i = 0; i < 2; i++) {
for (let i = 0; i < 2; i += 1) {
await strapi.query(uid).create({ data: { title: 'Test' } });
}

View File

@ -34,7 +34,7 @@ const processData = (metadata, data = {}, { withDefaults = false } = {}) => {
const obj = {};
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (types.isScalar(attribute.type)) {
@ -333,7 +333,7 @@ const createEntityManager = (db) => {
async attachRelations(uid, id, data) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
const isValidLink = _.has(attributeName, data) && !_.isNil(data[attributeName]);
@ -487,7 +487,7 @@ const createEntityManager = (db) => {
async updateRelations(uid, id, data) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attribute.type !== 'relation' || !_.has(attributeName, data)) {
@ -667,7 +667,7 @@ const createEntityManager = (db) => {
async deleteRelations(uid, id) {
const { attributes } = db.metadata.get(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attribute.type !== 'relation') {

View File

@ -54,7 +54,7 @@ const createLifecyclesProvider = (db) => {
* @param {Map<any, any>} states
*/
async run(action, uid, properties, states = new Map()) {
for (let i = 0; i < subscribers.length; i++) {
for (let i = 0; i < subscribers.length; i += 1) {
const subscriber = subscribers[i];
if (typeof subscriber === 'function') {
const state = states.get(subscriber) || {};

View File

@ -71,7 +71,7 @@ const applyJoin = (qb, join) => {
inner.on(`${rootTable}.${rootColumn}`, `${alias}.${referencedColumn}`);
if (on) {
for (const key in on) {
for (const key of Object.keys(on)) {
inner.onVal(`${alias}.${key}`, on[key]);
}
}

View File

@ -8,7 +8,7 @@ const { fromRow } = require('./transform');
const getRootLevelPopulate = (meta) => {
const populate = {};
for (const attributeName in meta.attributes) {
for (const attributeName of Object.keys(meta.attributes)) {
const attribute = meta.attributes[attributeName];
if (attribute.type === 'relation') {
populate[attributeName] = true;
@ -72,7 +72,7 @@ const processPopulate = (populate, ctx) => {
}
const finalPopulate = {};
for (const key in populateMap) {
for (const key of Object.keys(populateMap)) {
const attribute = meta.attributes[key];
if (!attribute) {
@ -119,7 +119,7 @@ const applyPopulate = async (results, populate, ctx) => {
return results;
}
for (const key in populate) {
for (const key of Object.keys(populate)) {
const attribute = meta.attributes[key];
const targetMeta = db.metadata.get(attribute.target);
@ -540,7 +540,7 @@ const applyPopulate = async (results, populate, ctx) => {
}, {});
const map = {};
for (const type in idsByType) {
for (const type of Object.keys(idsByType)) {
const ids = idsByType[type];
// type was removed but still in morph relation
@ -604,7 +604,7 @@ const applyPopulate = async (results, populate, ctx) => {
}, {});
const map = {};
for (const type in idsByType) {
for (const type of Object.keys(idsByType)) {
const ids = idsByType[type];
// type was removed but still in morph relation

View File

@ -53,7 +53,7 @@ const toRow = (meta, data = {}) => {
const { attributes } = meta;
for (const key in data) {
for (const key of Object.keys(data)) {
const attribute = attributes[key];
if (!attribute || attribute.columnName === key) {

View File

@ -76,7 +76,7 @@ const processAttributeWhere = (attribute, where, operator = '$eq') => {
const filters = {};
for (const key in where) {
for (const key of Object.keys(where)) {
const value = where[key];
if (!isOperator(key)) {
@ -119,7 +119,7 @@ const processWhere = (where, ctx) => {
const filters = {};
// for each key in where
for (const key in where) {
for (const key of Object.keys(where)) {
const value = where[key];
// if operator $and $or then loop over them

View File

@ -27,7 +27,13 @@ const createQueryBuilder = (uid, db) => {
};
let counter = 0;
const getAlias = () => `t${counter++}`;
const getAlias = () => {
const alias = `t${counter}`;
counter += 1;
return alias;
};
return {
alias: getAlias(),

View File

@ -25,7 +25,7 @@ const createTable = (meta) => {
columns: [],
};
for (const key in meta.attributes) {
for (const key of Object.keys(meta.attributes)) {
const attribute = meta.attributes[key];
if (types.isRelation(attribute.type)) {

View File

@ -9,7 +9,7 @@ const CHUNK_SIZE = 100;
* Will dump configurations to a file or stdout
* @param {string} file filepath to use as output
*/
module.exports = async function ({ file: filePath, pretty }) {
module.exports = async ({ file: filePath, pretty }) => {
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
const appContext = await strapi.compile();
@ -21,7 +21,7 @@ module.exports = async function ({ file: filePath, pretty }) {
const pageCount = Math.ceil(count / CHUNK_SIZE);
for (let page = 0; page < pageCount; page++) {
for (let page = 0; page < pageCount; page += 1) {
const results = await app
.query('strapi::core-store')
.findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });

View File

@ -56,7 +56,7 @@ const transformEntry = (entry, type) => {
const attributeValues = {};
for (const key in properties) {
for (const key of Object.keys(properties)) {
const property = properties[key];
const attribute = type && type.attributes[key];

View File

@ -40,7 +40,7 @@ module.exports = async (strapi) => {
validateContentTypesUnicity(apis);
for (const apiName in apis) {
for (const apiName of Object.keys(apis)) {
strapi.container.get('apis').add(apiName, apis[apiName]);
}
};

View File

@ -59,7 +59,9 @@ const getEnabledPlugins = async (strapi) => {
}
const installedPlugins = {};
for (const dep in strapi.config.get('info.dependencies', {})) {
const dependencies = strapi.config.get('info.dependencies', {});
for (const dep of Object.keys(dependencies)) {
const packagePath = join(dep, 'package.json');
let packageInfo;
try {

View File

@ -34,10 +34,10 @@ const applyUserExtension = async (plugins) => {
const extendedSchemas = await loadFiles(extensionsDir, '**/content-types/**/schema.json');
const strapiServers = await loadFiles(extensionsDir, '**/strapi-server.js');
for (const pluginName in plugins) {
for (const pluginName of Object.keys(plugins)) {
const plugin = plugins[pluginName];
// first: load json schema
for (const ctName in plugin.contentTypes) {
for (const ctName of Object.keys(plugin.contentTypes)) {
const extendedSchema = get([pluginName, 'content-types', ctName, 'schema'], extendedSchemas);
if (extendedSchema) {
plugin.contentTypes[ctName].schema = {
@ -57,7 +57,7 @@ const applyUserExtension = async (plugins) => {
const applyUserConfig = async (plugins) => {
const userPluginsConfig = await getUserPluginsConfig();
for (const pluginName in plugins) {
for (const pluginName of Object.keys(plugins)) {
const plugin = plugins[pluginName];
const userPluginConfig = getOr({}, `${pluginName}.config`, userPluginsConfig);
const defaultConfig =
@ -82,7 +82,7 @@ const loadPlugins = async (strapi) => {
strapi.config.set('enabledPlugins', enabledPlugins);
for (const pluginName in enabledPlugins) {
for (const pluginName of Object.keys(enabledPlugins)) {
const enabledPlugin = enabledPlugins[pluginName];
const serverEntrypointPath = join(enabledPlugin.pathToPlugin, 'strapi-server.js');
@ -100,7 +100,7 @@ const loadPlugins = async (strapi) => {
await applyUserConfig(plugins);
await applyUserExtension(plugins);
for (const pluginName in plugins) {
for (const pluginName of Object.keys(plugins)) {
strapi.container.get('plugins').add(pluginName, plugins[pluginName]);
}
};

View File

@ -5,7 +5,7 @@ const { createContentType } = require('../domain/content-type');
const { addNamespace, hasNamespace } = require('../utils');
const validateKeySameToSingularName = (contentTypes) => {
for (const ctName in contentTypes) {
for (const ctName of Object.keys(contentTypes)) {
const contentType = contentTypes[ctName];
if (ctName !== contentType.schema.info.singularName) {
@ -63,7 +63,7 @@ const contentTypesRegistry = () => {
add(namespace, newContentTypes) {
validateKeySameToSingularName(newContentTypes);
for (const rawCtName in newContentTypes) {
for (const rawCtName of Object.keys(newContentTypes)) {
const uid = addNamespace(rawCtName, namespace);
if (has(uid, contentTypes)) {

View File

@ -48,7 +48,7 @@ const controllersRegistry = () => {
const filteredControllers = pickBy((_, uid) => hasNamespace(uid, namespace))(controllers);
const map = {};
for (const uid in filteredControllers) {
for (const uid of Object.keys(filteredControllers)) {
Object.defineProperty(map, uid, {
enumerable: true,
get: () => {
@ -78,7 +78,7 @@ const controllersRegistry = () => {
* @returns
*/
add(namespace, newControllers) {
for (const controllerName in newControllers) {
for (const controllerName of Object.keys(newControllers)) {
const controller = newControllers[controllerName];
const uid = addNamespace(controllerName, namespace);

View File

@ -54,7 +54,7 @@ const hooksRegistry = () => {
* @returns
*/
add(namespace, hooks) {
for (const hookName in hooks) {
for (const hookName of Object.keys(hooks)) {
const hook = hooks[hookName];
const uid = addNamespace(hookName, namespace);

View File

@ -54,8 +54,8 @@ const middlewaresRegistry = () => {
* @param {{ [key: string]: Middleware }} newMiddlewares
* @returns
*/
add(namespace, rawMiddlewares) {
for (const middlewareName in rawMiddlewares) {
add(namespace, rawMiddlewares = {}) {
for (const middlewareName of Object.keys(rawMiddlewares)) {
const middleware = rawMiddlewares[middlewareName];
const uid = addNamespace(middlewareName, namespace);

View File

@ -55,7 +55,7 @@ const policiesRegistry = () => {
* @returns
*/
add(namespace, newPolicies) {
for (const policyName in newPolicies) {
for (const policyName of Object.keys(newPolicies)) {
const policy = newPolicies[policyName];
const uid = addNamespace(policyName, namespace);

View File

@ -48,7 +48,7 @@ const servicesRegistry = (strapi) => {
// create lazy accessor to avoid instantiating the services;
const map = {};
for (const uid in filteredServices) {
for (const uid of Object.keys(filteredServices)) {
Object.defineProperty(map, uid, {
enumerable: true,
get: () => {
@ -78,7 +78,7 @@ const servicesRegistry = (strapi) => {
* @returns
*/
add(namespace, newServices) {
for (const serviceName in newServices) {
for (const serviceName of Object.keys(newServices)) {
const service = newServices[serviceName];
const uid = addNamespace(serviceName, namespace);

View File

@ -9,7 +9,7 @@ const createCronService = () => {
return {
add(tasks = {}) {
for (const taskExpression in tasks) {
for (const taskExpression of Object.keys(tasks)) {
const taskValue = tasks[taskExpression];
let fn;

View File

@ -18,11 +18,11 @@ const omitComponentData = (contentType, data) => {
// NOTE: we could generalize the logic to allow CRUD of relation directly in the DB layer
const createComponents = async (uid, data) => {
const { attributes } = strapi.getModel(uid);
const { attributes = {} } = strapi.getModel(uid);
const componentBody = {};
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (!has(attributeName, data) || !contentTypesUtils.isComponentAttribute(attribute)) {
@ -118,11 +118,11 @@ const getComponents = async (uid, entity) => {
create or update
*/
const updateComponents = async (uid, entityToUpdate, data) => {
const { attributes } = strapi.getModel(uid);
const { attributes = {} } = strapi.getModel(uid);
const componentBody = {};
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (!has(attributeName, data)) {
@ -275,9 +275,9 @@ const deleteOldDZComponents = async (uid, entityToUpdate, attributeName, dynamic
};
const deleteComponents = async (uid, entityToDelete) => {
const { attributes } = strapi.getModel(uid);
const { attributes = {} } = strapi.getModel(uid);
for (const attributeName in attributes) {
for (const attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attribute.type === 'component') {

View File

@ -14,51 +14,56 @@ const { isMediaAttribute, isScalarAttribute, getWritableAttributes } = strapiUti
const { ValidationError } = strapiUtils.errors;
const addMinMax = (validator, { attr, updatedAttribute }) => {
let nextValidator = validator;
if (
Number.isInteger(attr.min) &&
(attr.required || (Array.isArray(updatedAttribute.value) && updatedAttribute.value.length > 0))
) {
validator = validator.min(attr.min);
nextValidator = nextValidator.min(attr.min);
}
if (Number.isInteger(attr.max)) {
validator = validator.max(attr.max);
nextValidator = nextValidator.max(attr.max);
}
return validator;
return nextValidator;
};
const addRequiredValidation =
(createOrUpdate) =>
(validator, { attr: { required } }) => {
const addRequiredValidation = (createOrUpdate) => {
return (validator, { attr: { required } }) => {
let nextValidator = validator;
if (required) {
if (createOrUpdate === 'creation') {
validator = validator.notNil();
nextValidator = nextValidator.notNil();
} else if (createOrUpdate === 'update') {
validator = validator.notNull();
nextValidator = nextValidator.notNull();
}
} else {
validator = validator.nullable();
nextValidator = nextValidator.nullable();
}
return validator;
return nextValidator;
};
};
const addDefault = (createOrUpdate) => {
return (validator, { attr }) => {
let nextValidator = validator;
const addDefault =
(createOrUpdate) =>
(validator, { attr }) => {
if (createOrUpdate === 'creation') {
if (
((attr.type === 'component' && attr.repeatable) || attr.type === 'dynamiczone') &&
!attr.required
) {
validator = validator.default([]);
nextValidator = nextValidator.default([]);
} else {
validator = validator.default(attr.default);
nextValidator = nextValidator.default(attr.default);
}
} else {
validator = validator.default(undefined);
nextValidator = nextValidator.default(undefined);
}
return validator;
return nextValidator;
};
};
const preventCast = (validator) => validator.transform((val, originalVal) => originalVal);

View File

@ -43,7 +43,7 @@ describe('Metrics middleware', () => {
const sendEvent = jest.fn();
const middleware = createMiddleware({ sendEvent });
for (let i = 0; i < 2000; i++) {
for (let i = 0; i < 2000; i += 1) {
await middleware(
{
request: {

View File

@ -22,7 +22,7 @@ const createMiddleware = ({ sendEvent }) => {
sendEvent('didReceiveRequest', { url: ctx.request.url });
// Increase counter.
_state.counter++;
_state.counter += 1;
}
}

View File

@ -50,7 +50,7 @@ const registerAdminRoutes = (strapi) => {
* @param {import('../../').Strapi} strapi
*/
const registerPluginRoutes = (strapi) => {
for (const pluginName in strapi.plugins) {
for (const pluginName of Object.keys(strapi.plugins)) {
const plugin = strapi.plugins[pluginName];
const generateRouteScope = createRouteScopeGenerator(`plugin::${pluginName}`);
@ -86,7 +86,7 @@ const registerPluginRoutes = (strapi) => {
* @param {import('../../').Strapi} strapi
*/
const registerAPIRoutes = (strapi) => {
for (const apiName in strapi.api) {
for (const apiName of Object.keys(strapi.api)) {
const api = strapi.api[apiName];
const generateRouteScope = createRouteScopeGenerator(`api::${apiName}`);

View File

@ -27,7 +27,7 @@ module.exports = async (uid, entity, files) => {
let tmpModel = modelDef;
let modelUID = uid;
for (let i = 0; i < path.length; i++) {
for (let i = 0; i < path.length; i += 1) {
if (!tmpModel) return {};
const part = path[i];
const attr = tmpModel.attributes[part];

View File

@ -26,7 +26,7 @@ module.exports = class WorkerQueue {
enqueue(payload) {
debug('Enqueue event in worker queue');
if (this.running < this.concurrency) {
this.running++;
this.running += 1;
this.execute(payload);
} else {
this.queue.unshift(payload);
@ -40,7 +40,7 @@ module.exports = class WorkerQueue {
if (payload) {
this.execute(payload);
} else {
this.running--;
this.running -= 1;
}
}

View File

@ -1,10 +1,11 @@
'use strict';
module.exports = (path) => {
if (typeof path !== 'string') throw new Error('admin.url must be a string');
if (path === '' || path === '/') return '/';
let tmpPath = path;
if (typeof tmpPath !== 'string') throw new Error('admin.url must be a string');
if (tmpPath === '' || tmpPath === '/') return '/';
if (path[0] != '/') path = `/${path}`;
if (path[path.length - 1] != '/') path += '/';
return path;
if (tmpPath[0] !== '/') tmpPath = `/${tmpPath}`;
if (tmpPath[tmpPath.length - 1] !== '/') tmpPath += '/';
return tmpPath;
};

View File

@ -21,7 +21,7 @@ const getAssociationFromFieldKey = ({ model, field }) => {
let association;
let attribute;
for (let i = 0; i < fieldParts.length; i++) {
for (let i = 0; i < fieldParts.length; i += 1) {
const part = fieldParts[i];
attribute = part;

View File

@ -11,6 +11,7 @@ const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
function printNumber(val) {
// eslint-disable-next-line eqeqeq
if (val != +val) return 'NaN';
const isNegativeZero = val === 0 && 1 / val < 0;
return isNegativeZero ? '-0' : `${val}`;

View File

@ -61,7 +61,7 @@ async function askDbInfosAndTest(scope) {
.then((result) => {
if (result && result.shouldRetry === true && retries < MAX_RETRIES - 1) {
console.log('Retrying...');
retries++;
retries += 1;
return loop();
}
})
@ -86,7 +86,7 @@ async function askDbInfosAndTest(scope) {
}
console.log('Retrying...');
retries++;
retries += 1;
return loop();
}

View File

@ -15,12 +15,13 @@ module.exports = ({ strapi }) => {
return {
registerDoc(doc) {
let registeredDoc = doc;
// parseYaml
if (typeof doc === 'string') {
doc = require('yaml').parse(doc);
registeredDoc = require('yaml').parse(registeredDoc);
}
// receive an object we can register it directly
registeredDocs.push(doc);
registeredDocs.push(registeredDoc);
},
getDocumentationVersion() {
return _.get(config, 'info.version');

View File

@ -147,7 +147,7 @@ module.exports = {
.query('plugin::users-permissions.user')
.findOne({ where: { username } });
if (userWithSameUsername && userWithSameUsername.id != id) {
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(id)) {
throw new ApplicationError('Username already taken');
}
}
@ -157,7 +157,7 @@ module.exports = {
.query('plugin::users-permissions.user')
.findOne({ where: { email: _.toLower(email) } });
if (userWithSameEmail && userWithSameEmail.id != id) {
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(id)) {
throw new ApplicationError('Email already taken');
}
body.email = _.toLower(body.email);

View File

@ -105,7 +105,7 @@ module.exports = {
.query('plugin::users-permissions.user')
.findOne({ where: { username } });
if (userWithSameUsername && userWithSameUsername.id != id) {
if (userWithSameUsername && _.toString(userWithSameUsername.id) !== _.toString(id)) {
throw new ApplicationError('Username already taken');
}
}
@ -115,7 +115,7 @@ module.exports = {
.query('plugin::users-permissions.user')
.findOne({ where: { email: email.toLowerCase() } });
if (userWithSameEmail && userWithSameEmail.id != id) {
if (userWithSameEmail && _.toString(userWithSameEmail.id) !== _.toString(id)) {
throw new ApplicationError('Email already taken');
}
ctx.request.body.email = ctx.request.body.email.toLowerCase();

View File

@ -13,10 +13,10 @@ const printResults = (results) => {
Object.entries(pkgs).forEach(([packageName, keys]) => {
keys.forEach((key) => {
console.log(`"${chalk.yellow(value)}" ${packageName} ${chalk.blue(key)}`);
keysCount++;
keysCount += 1;
});
});
valuesCount++;
valuesCount += 1;
console.log();
});

View File

@ -137,10 +137,10 @@ const merge = async (valuesToMerge) => {
valueGroup.forEach((keyGroup) => {
updateTranslationFiles(keyGroup, targetKey);
keyGroup.replaceAll(`id: '${targetKey}'`);
mergedCount++;
mergedCount += 1;
});
}
current++;
current += 1;
}
console.log(`Merged ${mergedCount} keys`);

View File

@ -25,7 +25,7 @@ async function run() {
}
const server = http.createServer((req, res) => {
if (req.url == '/spec.yml') {
if (req.url === '/spec.yml') {
return fse.createReadStream(openAPISpecPath).pipe(res);
}

View File

@ -12,11 +12,11 @@ Object.defineProperty(global, 'strapi', {
strapiInstance = value;
strapiInstance.plugin = (name) => strapiInstance.plugins[name];
_.mapValues(strapi.plugins, (plugin) => {
plugin.controller = (name) => plugin.controllers[name];
plugin.service = (name) => plugin.services[name];
plugin.contentType = (name) => plugin.contentTypes[name];
plugin.policy = (name) => plugin.policies[name];
_.mapValues(strapi.plugins, (acc) => {
acc.controller = (name) => acc.controllers[name];
acc.service = (name) => acc.services[name];
acc.contentType = (name) => acc.contentTypes[name];
acc.policy = (name) => acc.policies[name];
});
strapiInstance.service = (name = '') => {