@sap/eslint-plugin-cds
Version:
ESLint plugin including recommended SAP Cloud Application Programming model and environment rules
47 lines (41 loc) • 1.36 kB
JavaScript
/**
* ## Plugin structure
* This is the main entry point of our [custom ESLint plugin](https://eslint.org/docs/developer-guide/working-with-plugins),
* which exposes sets of [rules]() along with their [severity configurations]() to the [ESLint Cli]() or [API]().
* @module
*/
/**
* Custom ESLint plugin:
* https://eslint.org/docs/developer-guide/working-with-plugins
* This file exposes our plugins' ESLint configuration, which must:
* - Expose any 'configs' for prescribed rule configuration bundles
* (i.e. "recommended"). See shareable configs:
* https://eslint.org/docs/developer-guide/shareable-configs
* - Expose any 'rules' for use in ESLint
*/
const api = require('./api')
const getConfigs = require('./conf')
const rules = Object.assign(
{},
...Object.entries(require('./rules')).map(([k, v]) => ({ [k]: v() }))
)
const packageJson = require('../package.json')
const plugin = {
meta: {
name: packageJson.name,
version: packageJson.version
},
configs: {},
rules,
...api
}
// Use commonJS entry point to ensure backwards compatibility (<eslint@v9):
// https://eslint.org/docs/latest/extend/plugin-migration-flat-config#backwards-compatibility
// spread and mix object to be able to reference plugin in getConfigs
module.exports = {
...plugin,
...{
configs: getConfigs(plugin)
}
}