不要怂,就是干,撸起袖子干!

Commit 9bc6d425 by supperchong Committed by Sushant

chores(styling): add spacing around infix operators rules in eslint (#11282)

1 parent 748f6908
......@@ -34,23 +34,12 @@
"properties": false
}
],
"semi": [
"error",
"always"
],
"space-before-function-paren": [
"error",
"never"
],
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"space-before-blocks": "error",
"arrow-parens": [
"error",
"as-needed"
],
"comma-style": [
"error",
"last"
],
"space-infix-ops": "error",
"arrow-parens": ["error", "as-needed"],
"comma-style": ["error", "last"],
"indent": [
"error",
2,
......@@ -73,25 +62,16 @@
// functional
"valid-jsdoc": "off",
"strict": [
"error",
"global"
],
"strict": ["error", "global"],
"no-var": "error",
"prefer-const": "error",
"prefer-arrow-callback": "error",
"no-extend-native": "error",
"wrap-iife": [
"error",
"any"
],
"wrap-iife": ["error", "any"],
"no-use-before-define": "off",
"no-caller": "error",
"no-irregular-whitespace": "error",
"max-depth": [
"error",
6
],
"max-depth": ["error", 6],
"no-loop-func": "warn",
"object-shorthand": "error",
"one-var-declaration-per-line": "error",
......@@ -116,10 +96,7 @@
"ecmaVersion": 6,
"sourceType": "script"
},
"plugins": [
"mocha",
"jsdoc"
],
"plugins": ["mocha", "jsdoc"],
"env": {
"node": true,
"mocha": true,
......
......@@ -346,7 +346,7 @@ class QueryGenerator {
const values = [];
const bind = [];
const modelAttributeMap = {};
let outputFragment ='';
let outputFragment = '';
let tmpTable = ''; // tmpTable declaration for trigger
let selectFromTmp = ''; // Select statement for trigger
let suffix = '';
......@@ -2197,7 +2197,7 @@ class QueryGenerator {
// OR/AND/NOT grouping logic
_whereGroupBind(key, value, options) {
const binding = key === Op.or ? this.OperatorMap[Op.or] : this.OperatorMap[Op.and];
const outerBinding = key === Op.not ? 'NOT ': '';
const outerBinding = key === Op.not ? 'NOT ' : '';
if (Array.isArray(value)) {
value = value.map(item => {
......
......@@ -166,7 +166,7 @@ class Query extends AbstractQuery {
logWarnings(results) {
return this.run('SHOW WARNINGS').then(warningResults => {
const warningMessage = `MySQL Warnings (${this.connection.uuid||'default'}): `;
const warningMessage = `MySQL Warnings (${this.connection.uuid || 'default'}): `;
const messages = [];
for (const _warningRow of warningResults) {
if (_warningRow === undefined || typeof _warningRow[Symbol.iterator] !== 'function') continue;
......
......@@ -134,7 +134,7 @@ class Query extends AbstractQuery {
return {
attribute: field,
collate: attribute.match(/COLLATE "(.*?)"/) ? /COLLATE "(.*?)"/.exec(attribute)[1] : undefined,
order: attribute.includes('DESC') ? 'DESC' : attribute.includes('ASC') ? 'ASC': undefined,
order: attribute.includes('DESC') ? 'DESC' : attribute.includes('ASC') ? 'ASC' : undefined,
length: undefined
};
}).filter(n => n !== null);
......@@ -152,9 +152,9 @@ class Query extends AbstractQuery {
row.from = defParts[1];
row.to = defParts[3];
let i;
for (i=5;i<=8;i+=3) {
for (i = 5;i <= 8;i += 3) {
if (/(UPDATE|DELETE)/.test(defParts[i])) {
row[`on_${defParts[i].toLowerCase()}`] = defParts[i+1];
row[`on_${defParts[i].toLowerCase()}`] = defParts[i + 1];
}
}
}
......
......@@ -30,7 +30,7 @@ class Query extends AbstractQuery {
if (Array.isArray(values)) {
bindParam = {};
values.forEach((v, i) => {
bindParam[`$${i+1}`] = v;
bindParam[`$${i + 1}`] = v;
});
sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
} else {
......@@ -329,7 +329,7 @@ class Query extends AbstractQuery {
const constraint = constraintSql.split(' ');
if (constraint[1] === 'PRIMARY' || constraint[1] === 'FOREIGN') {
constraint[1]+= ' KEY';
constraint[1] += ' KEY';
}
return {
......
......@@ -669,7 +669,7 @@ class Model {
}
if (include.association.scope) {
include.where = include.where ? { [Op.and]: [include.where, include.association.scope] }: include.association.scope;
include.where = include.where ? { [Op.and]: [include.where, include.association.scope] } : include.association.scope;
}
if (include.limit && include.separate === undefined) {
......@@ -2281,7 +2281,7 @@ class Model {
static findOrCreate(options) {
if (!options || !options.where || arguments.length > 1) {
throw new Error(
'Missing where attribute in the options parameter passed to findOrCreate. '+
'Missing where attribute in the options parameter passed to findOrCreate. ' +
'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
);
}
......
......@@ -1160,7 +1160,7 @@ class Sequelize {
// remove options from set of logged arguments if options.logging is equal to console.log
// eslint-disable-next-line no-console
if (options.logging === console.log) {
args.splice(args.length-1, 1);
args.splice(args.length - 1, 1);
}
} else {
options = this.options;
......
......@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
validate: { isInt: true },
set(val) {
this.setDataValue('validateSideEffect', val);
this.setDataValue('validateSideAffected', val*2);
this.setDataValue('validateSideAffected', val * 2);
}
},
validateSideAffected: {
......
......@@ -854,7 +854,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('adds a new dao to the dao manager', function() {
const count = this.sequelize.modelManager.all.length;
this.sequelize.define('foo', { title: DataTypes.STRING });
expect(this.sequelize.modelManager.all.length).to.equal(count+1);
expect(this.sequelize.modelManager.all.length).to.equal(count + 1);
});
it('adds a new dao to sequelize.models', function() {
......
......@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
if (Support.getTestDialect() !== 'mssql') {
it('accepts condition object (with cast)', function() {
const type = Support.getTestDialect() === 'mysql' ? 'unsigned': 'int';
const type = Support.getTestDialect() === 'mysql' ? 'unsigned' : 'int';
return Airplane.findAll({
attributes: [
......
......@@ -119,7 +119,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
describe('timestamps', () => {
it('follows the global timestamps true option', () => {
const User =current.define('User', {}),
const User = current.define('User', {}),
Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task1' });
......@@ -128,7 +128,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
});
it('allows me to override the global timestamps option', () => {
const User =current.define('User', {}),
const User = current.define('User', {}),
Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task2', timestamps: false });
......@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
timestamps: false
});
const User =current.define('User', {}),
const User = current.define('User', {}),
Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task3' });
......@@ -151,14 +151,14 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
});
describe('optimizations using bulk create, destroy and update', () => {
const User =current.define('User', { username: DataTypes.STRING }),
const User = current.define('User', { username: DataTypes.STRING }),
Task = current.define('Task', { title: DataTypes.STRING }),
UserTasks = current.define('UserTasks', {});
User.belongsToMany(Task, { through: UserTasks });
Task.belongsToMany(User, { through: UserTasks });
const user =User.build({
const user = User.build({
id: 42
}),
task1 = Task.build({
......@@ -497,7 +497,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
describe('self-associations', () => {
it('does not pair multiple self associations with different through arguments', () => {
const User =current.define('user', {}),
const User = current.define('user', {}),
UserFollowers = current.define('userFollowers', {}),
Invite = current.define('invite', {});
......@@ -519,7 +519,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
});
it('correctly generates a foreign/other key when none are defined', () => {
const User =current.define('user', {}),
const User = current.define('user', {}),
UserFollowers = current.define('userFollowers', {
id: {
type: DataTypes.INTEGER,
......
......@@ -22,7 +22,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
});
describe('optimizations using bulk create, destroy and update', () => {
const User =current.define('User', { username: DataTypes.STRING }),
const User = current.define('User', { username: DataTypes.STRING }),
Task = current.define('Task', { title: DataTypes.STRING });
User.hasMany(Task);
......@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
});
describe('mixin', () => {
const User =current.define('User'),
const User = current.define('User'),
Task = current.define('Task');
it('should mixin association methods', () => {
......@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
});
describe('get', () => {
const User =current.define('User', {}),
const User = current.define('User', {}),
Task = current.define('Task', {}),
idA = Math.random().toString(),
idB = Math.random().toString(),
......
......@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 1 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 5 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [User];`
});
......@@ -124,7 +124,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;`
});
......@@ -155,7 +155,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;`
});
......@@ -187,7 +187,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;`
});
}());
......@@ -273,7 +273,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`,
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id];`
});
......@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id] LEFT OUTER JOIN [comment] AS [POSTS->COMMENTS] ON [POSTS].[id] = [POSTS->COMMENTS].[post_id];`
});
})();
......
......@@ -20,7 +20,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
options = undefined;
}
it(util.inspect(params, { depth: 10 })+(options && `, ${util.inspect(options)}` || ''), () => {
it(util.inspect(params, { depth: 10 }) + (options && `, ${util.inspect(options)}` || ''), () => {
const sqlOrError = _.attempt(sql.whereQuery.bind(sql), params, options);
return expectsql(sqlOrError, expectation);
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!