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

Commit 8d4700fb by Felix Becker Committed by GitHub

style(spacing): add spacing rules to .eslintrc (#7921)

Requires a spaces after an if and before the opening brace of blocks
1 parent 18e04a2b
......@@ -11,7 +11,8 @@
"prefer-const": "error",
"semi": ["error", "always"],
"space-before-function-paren": ["warn", "never"],
"keyword-spacing": ["warn"],
"space-before-blocks": ["error"],
"keyword-spacing": ["error"],
"prefer-arrow-callback": "error",
"arrow-parens": ["error", "as-needed"],
"comma-style": ["warn", "last"],
......
......@@ -115,10 +115,10 @@ const QueryGenerator = {
let outputColumns = '';
tmpTable = 'declare @tmp table (<%= columns %>); ';
for (const modelKey in modelAttributes){
for (const modelKey in modelAttributes) {
const attribute = modelAttributes[modelKey];
if (!(attribute.type instanceof DataTypes.VIRTUAL)){
if (tmpColumns.length > 0){
if (!(attribute.type instanceof DataTypes.VIRTUAL)) {
if (tmpColumns.length > 0) {
tmpColumns += ',';
outputColumns += ',';
}
......@@ -307,10 +307,10 @@ const QueryGenerator = {
let tmpColumns = '';
let outputColumns = '';
for (const modelKey in attributes){
for (const modelKey in attributes) {
const attribute = attributes[modelKey];
if (!(attribute.type instanceof DataTypes.VIRTUAL)){
if (tmpColumns.length > 0){
if (!(attribute.type instanceof DataTypes.VIRTUAL)) {
if (tmpColumns.length > 0) {
tmpColumns += ',';
outputColumns += ',';
}
......@@ -726,7 +726,7 @@ const QueryGenerator = {
connector = connector || '.';
// just quote as identifiers if string
if (typeof collection === 'string'){
if (typeof collection === 'string') {
return this.quoteIdentifiers(collection);
} else if (Array.isArray(collection)) {
// iterate through the collection and mutate objects into associations
......@@ -736,7 +736,7 @@ const QueryGenerator = {
let previousModel;
// set the previous as the parent when previous is undefined or the target of the association
if (!previous && parent !== undefined){
if (!previous && parent !== undefined) {
previousModel = parent;
} else if (previous && previous instanceof Association) {
previousAssociation = previous;
......@@ -1682,7 +1682,7 @@ const QueryGenerator = {
}
mainQueryOrder.push(this.quote(order, model, '->'));
}
} else if (options.order instanceof Utils.SequelizeMethod){
} else if (options.order instanceof Utils.SequelizeMethod) {
const sql = this.quote(options.order, model, '->');
if (subQuery) {
subQueryOrder.push(sql);
......
......@@ -869,7 +869,7 @@ const QueryGenerator = {
};
// private methods
function wrapSingleQuote(identifier){
function wrapSingleQuote(identifier) {
return Utils.addTicks(Utils.removeTicks(identifier, "'"), "'");
}
......
......@@ -33,7 +33,7 @@ class Query extends AbstractQuery {
const paramType = {type: TYPES.VarChar, typeOptions: {} };
paramType.type = TYPES.NVarChar;
if (typeof value === 'number') {
if(Number.isInteger(value)){
if (Number.isInteger(value)) {
paramType.type = TYPES.Int;
} else {
paramType.type = TYPES.Numeric;
......@@ -110,7 +110,7 @@ class Query extends AbstractQuery {
}
});
if(parameters){
if (parameters) {
_.forOwn(parameters, (value, key) => {
const paramType = this.getSQLTypeFromJsType(value);
request.addParameter(key, paramType.type, value, paramType.typeOptions);
......
......@@ -365,7 +365,7 @@ const QueryGenerator = {
};
// private methods
function wrapSingleQuote(identifier){
function wrapSingleQuote(identifier) {
return Utils.addTicks(identifier, '\'');
}
......
......@@ -159,7 +159,7 @@ class ConnectionManager extends AbstractConnectionManager {
type = dataTypes.postgres.GEOMETRY;
} else if (row.typname === 'hstore') {
type = dataTypes.postgres.HSTORE;
} else if (row.typname === 'geography'){
} else if (row.typname === 'geography') {
type = dataTypes.postgres.GEOGRAPHY;
}
......
......@@ -290,10 +290,10 @@ module.exports = BaseTypes => {
GEOMETRY.prototype.toSql = function toSql() {
let result = this.key;
if (this.type){
if (this.type) {
result += '(' + this.type;
if (this.srid){
if (this.srid) {
result += ',' + this.srid;
}
......@@ -326,10 +326,10 @@ module.exports = BaseTypes => {
GEOGRAPHY.prototype.toSql = function toSql() {
let result = 'GEOGRAPHY';
if (this.type){
if (this.type) {
result += '(' + this.type;
if (this.srid){
if (this.srid) {
result += ',' + this.srid;
}
......
......@@ -56,7 +56,7 @@ class Query extends AbstractQuery {
run(sql, parameters) {
this.sql = sql;
if (!Utils._.isEmpty(this.options.searchPath)){
if (!Utils._.isEmpty(this.options.searchPath)) {
this.sql = this.sequelize.queryInterface.QueryGenerator.setSearchPath(this.options.searchPath) + sql;
}
......
......@@ -579,7 +579,7 @@ class Model {
}
} else {
association = this.getAssociationForAlias(targetModel, targetAlias);
if (!association){
if (!association) {
throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is associated to ${this.name} multiple times. ` +
'To identify the correct association, you must use the \'as\' keyword to specify the alias of the association you want to include.');
}
......
......@@ -207,7 +207,7 @@ class Sequelize {
let Dialect;
// Requiring the dialect in a switch-case to keep the
// require calls static. (Browserify fix)
switch (this.getDialect()){
switch (this.getDialect()) {
case 'mssql':
Dialect = require('./dialects/mssql');
break;
......@@ -362,7 +362,7 @@ class Sequelize {
*/
import(path) {
// is it a relative path?
if (Path.normalize(path) !== Path.resolve(path)){
if (Path.normalize(path) !== Path.resolve(path)) {
// make path relative to the caller
const callerFilename = Utils.stack()[1].getFileName();
const callerPath = Path.dirname(callerFilename);
......@@ -1028,7 +1028,7 @@ class Sequelize {
options = last;
// remove options from set of logged arguments if options.logging is equal to console.log
if (options.logging === console.log){
if (options.logging === console.log) {
args.splice(args.length-1, 1);
}
} else {
......
......@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
describe('preserves changes to instance', () => {
it('beforeValidate', function(){
it('beforeValidate', function() {
let hookCalled = 0;
this.User.beforeValidate(user => {
......
......@@ -97,7 +97,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
describe('preserves changes to instance', () => {
it('beforeValidate', function(){
it('beforeValidate', function() {
this.User.beforeValidate(user => {
user.mood = 'happy';
......
......@@ -74,7 +74,7 @@ if (Support.sequelize.dialect.supports.upserts) {
});
describe('preserves changes to values', () => {
it('beforeUpsert', function(){
it('beforeUpsert', function() {
let hookCalled = 0;
const valuesOriginal = { mood: 'sad', username: 'leafninja' };
......
......@@ -32,7 +32,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
username: 'tony'
}
},
includeActiveProjects(){
includeActiveProjects() {
return {
include: [{
model: sequelize.models.company,
......
......@@ -520,7 +520,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
if (dialect === 'postgres' || dialect === 'sqlite') {
expect(logSql.indexOf('$1')).to.be.above(-1);
expect(logSql.indexOf('$2')).to.be.above(-1);
} else if (dialect === 'mssql'){
} else if (dialect === 'mssql') {
expect(logSql.indexOf('@0')).to.be.above(-1);
expect(logSql.indexOf('@1')).to.be.above(-1);
}
......
......@@ -248,7 +248,7 @@ if (current.dialect.supports.transactions) {
});
});
if (dialect === 'sqlite'){
if (dialect === 'sqlite') {
it('provides persistent transactions', () => {
const sequelize = new Support.Sequelize('database', 'username', 'password', {dialect: 'sqlite'}),
User = sequelize.define('user', {
......
......@@ -25,25 +25,25 @@ describe(Support.getTestDialectTeaser('associations'), () => {
this.C = this.sequelize.define('C', {});
});
it('should not be overwritten for belongsTo', function(){
it('should not be overwritten for belongsTo', function() {
const reqValidForeignKey = { foreignKey: { allowNull: false }};
this.A.belongsTo(this.B, reqValidForeignKey);
this.A.belongsTo(this.C, reqValidForeignKey);
expect(this.A.attributes.CId.type).to.deep.equal(this.C.attributes.id.type);
});
it('should not be overwritten for belongsToMany', function(){
it('should not be overwritten for belongsToMany', function() {
const reqValidForeignKey = { foreignKey: { allowNull: false }, through: 'ABBridge'};
this.B.belongsToMany(this.A, reqValidForeignKey);
this.A.belongsTo(this.C, reqValidForeignKey);
expect(this.A.attributes.CId.type).to.deep.equal(this.C.attributes.id.type);
});
it('should not be overwritten for hasOne', function(){
it('should not be overwritten for hasOne', function() {
const reqValidForeignKey = { foreignKey: { allowNull: false }};
this.B.hasOne(this.A, reqValidForeignKey);
this.A.belongsTo(this.C, reqValidForeignKey);
expect(this.A.attributes.CId.type).to.deep.equal(this.C.attributes.id.type);
});
it('should not be overwritten for hasMany', function(){
it('should not be overwritten for hasMany', function() {
const reqValidForeignKey = { foreignKey: { allowNull: false }};
this.B.hasMany(this.A, reqValidForeignKey);
this.A.belongsTo(this.C, reqValidForeignKey);
......
......@@ -15,7 +15,7 @@ describe('Transaction', function() {
this.stubConnection = sinon.stub(current.connectionManager, 'getConnection')
.returns(Sequelize.Promise.resolve({
uuid: 'ssfdjd-434fd-43dfg23-2d',
close(){}
close() {}
}));
this.stubRelease = sinon.stub(current.connectionManager, 'releaseConnection')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!