Ghost/.eslintrc.js
Hannah Wolfe ba6f51850e
Added complexity rule for api query methods [warn]
- We want to keep behaviour in services and libraries, not in API endpoints
- This rule runs complexity _only_ on the query methods, and has it set super low - just 3
- Methods that have higher complexity are a great indicator of places where we've left behaviour in the API, however!
- It's indicative, not definitive. At least with an eslint rule we can if needs be disable it where we decide the code is OK
2021-05-07 20:41:14 +01:00

67 lines
1.9 KiB
JavaScript

const path = require('path');
module.exports = {
env: {
es6: true,
node: true
},
plugins: ['ghost'],
extends: [
'plugin:ghost/node'
],
rules: {
// @TODO: remove this rule once it's turned into "error" in the base plugin
'no-shadow': 'error',
'no-var': 'error',
'one-var': [2, 'never']
},
overrides: [
{
files: 'core/server/api/canary/*',
rules: {
'ghost/ghost-custom/max-api-complexity': 'warn'
}
},
{
files: 'core/shared/**',
rules: {
'ghost/node/no-restricted-require': ['warn', [
{
name: path.resolve(__dirname, 'core/server/**'),
message: 'Invalid require of core/server from core/shared.'
},
{
name: path.resolve(__dirname, 'core/server/**'),
message: 'Invalid require of core/frontend from core/shared.'
}
]]
}
},
/**
* @TODO: enable these soon
*/
{
files: 'core/frontend/**',
rules: {
'ghost/node/no-restricted-require': ['off', [
{
name: path.resolve(__dirname, 'core/server/**'),
message: 'Invalid require of core/server from core/frontend.'
}
]]
}
},
{
files: 'core/server/**',
rules: {
'ghost/node/no-restricted-require': ['off', [
{
name: path.resolve(__dirname, 'core/frontend/**'),
message: 'Invalid require of core/frontend from core/server.'
}
]]
}
}
]
};