mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added lint warnings for bad patterns in migrations
refs: https://github.com/TryGhost/Toolbox/issues/105 The idea here is to ensure we're at least warning on bad migrations patterns. If a pattern is already in use in an existing migration, we can use `eslint-disable-next-line no-restricted-syntax` to override it. For new migrations which still need these features this step will force the user to think about the performance of the construct they are using
This commit is contained in:
parent
8c93bdff41
commit
e28a3769a7
1 changed files with 32 additions and 0 deletions
32
.eslintrc.js
32
.eslintrc.js
|
@ -22,6 +22,38 @@ module.exports = {
|
|||
'ghost/ghost-custom/max-api-complexity': 'error'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: 'core/server/data/migrations/versions/**',
|
||||
excludedFiles: [
|
||||
'core/server/data/migrations/versions/1.*/*',
|
||||
'core/server/data/migrations/versions/2.*/*',
|
||||
'core/server/data/migrations/versions/3.*/*'
|
||||
]
|
||||
},
|
||||
{
|
||||
files: 'core/server/data/migrations/versions/**',
|
||||
rules: {
|
||||
'no-restricted-syntax': ['warn', {
|
||||
selector: 'ForStatement',
|
||||
message: 'For statements can perform badly in migrations'
|
||||
}, {
|
||||
selector: 'WhileStatement',
|
||||
message: 'While statements can perform badly in migrations'
|
||||
}, {
|
||||
selector: 'CallExpression[callee.property.name=\'forEach\']',
|
||||
message: 'Loop constructs like forEach can perform badly in migrations'
|
||||
}, {
|
||||
selector: 'CallExpression[callee.object.name=\'_\'][callee.property.name=\'each\']',
|
||||
message: 'Loop constructs like _.each can perform badly in migrations'
|
||||
}, {
|
||||
selector: 'ForStatement ReturnStatement',
|
||||
message: 'Invalid use of a return statement within for-loop in a migration'
|
||||
}, {
|
||||
selector: 'CallExpression[callee.property.name=/join|innerJoin|leftJoin/] CallExpression[callee.property.name=/join|innerJoin|leftJoin/] CallExpression[callee.name=\'knex\']',
|
||||
message: 'Use of multiple join statements in a single knex block'
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
files: 'core/shared/**',
|
||||
rules: {
|
||||
|
|
Loading…
Add table
Reference in a new issue