eslint-plugin-better-cap-config
v1.1.0
Published
ESLint plugin to detect deprecated SAP CAP configurations
Maintainers
Readme
ESLint Plugin Better CAP Config
An ESLint plugin for improving SAP CAP (Cloud Application Programming Model) configuration patterns in JSON files.
Features
- Detects deprecated SAP CAP configuration patterns
- Works with
package.json,.cdsrc.json, and other CDS configuration files - Modern ESLint v9+ support with flat config
Installation
npm install --save-dev eslint @eslint/json eslint-plugin-better-cap-configRules
| Rule | Description |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| cds-cdsc-newparser | Disallow deprecated cds.cdsc.newparser: false configuration |
| cds-drafts-cancellation-timeout | Disallow deprecated cds.drafts.cancellationTimeout configuration |
| cds-features-async-handler-compat | Disallow deprecated cds.features.async_handler_compat configuration |
| cds-features-base64-binaries | Disallow deprecated cds.features.base64_binaries configuration |
| cds-features-bulk-inserts-via-rest | Disallow deprecated cds.features.bulk_inserts_via_rest: false configuration |
| cds-features-cds-validate | Disallow deprecated cds.features.cds_validate configuration |
| cds-features-compat-assert-not-null | Disallow deprecated cds.features.compat_assert_not_null configuration |
| cds-features-compat-clone-appends | Disallow deprecated cds.features.compat_clone_appends configuration |
| cds-features-compat-restrict-bound | Disallow deprecated cds.features.compat_restrict_bound configuration |
| cds-features-compat-restrict-where | Disallow deprecated cds.features.compat_restrict_where configuration |
| cds-features-compat-save-drafts | Disallow deprecated cds.features.compat_save_drafts configuration |
| cds-features-compat-srv-getters | Disallow deprecated cds.features.compat_srv_getters configuration |
| cds-features-compat-static-auth | Disallow deprecated cds.features.compat_static_auth configuration |
| cds-features-compat-texts-entities | Disallow deprecated cds.features.compat_texts_entities configuration |
| cds-features-compile-for-flows | Disallow deprecated cds.features.compile_for_flows configuration |
| cds-features-consistent-params | Disallow deprecated cds.features.consistent_params: false configuration |
| cds-features-keys-in-data-compat | Disallow deprecated cds.features.keys_in_data_compat configuration |
| cds-features-kibana-formatter | Disallow deprecated cds.features.kibana_formatter configuration |
| cds-features-legacy-srv-results | Disallow deprecated cds.features.legacy_srv_results: true configuration |
| cds-features-new-draft-via-action | Disallow deprecated cds.features.new_draft_via_action configuration |
| cds-features-odata-metadata-compat | Disallow deprecated cds.features.odata_metadata_compat configuration |
| cds-features-odata-new-adapter | Disallow deprecated cds.features.odata_new_adapter configuration |
| cds-features-serve-on-root | Disallow deprecated cds.features.serve_on_root: true configuration |
| cds-features-service-level-restrictions | Disallow deprecated cds.features.service_level_restrictions: false configuration |
| cds-features-stream-compat | Disallow deprecated cds.features.stream_compat configuration |
| cds-features-xssec-compat | Disallow deprecated cds.features.xssec_compat configuration |
| cds-fiori-calc-elements | Disallow deprecated cds.fiori.calc_elements configuration |
| cds-fiori-draft-compat | Disallow deprecated cds.fiori.draft_compat configuration |
| cds-fiori-direct-crud | Disallow deprecated cds.fiori.direct_crud configuration |
| cds-fiori-lean-draft | Disallow deprecated cds.fiori.lean_draft: false configuration |
| cds-i18n-fatjson | Disallow deprecated cds.i18n.fatjson configuration |
| cds-log-kibana-custom-fields | Disallow deprecated cds.log.kibana_custom_fields configuration |
| cds-mcp-auto-config | Disallow deprecated cds.mcp.autoConfig configuration (renamed to autoWired) |
| cds-multitenant-client-cert-header | Disallow deprecated cds.multiTenancy.subscriptionManager.clientCertificateHeader configuration |
| cds-remote-native-fetch | Disallow deprecated cds.remote.native_fetch configuration |
| cds-requires-db-database | Disallow deprecated cds.requires.db.database configuration |
| cds-requires-middlewares | Disallow deprecated cds.requires.middlewares: false configuration |
| cds-sql-collate | Disallow deprecated cds.sql.collate configuration |
| cds-sql-native-hana-associations | Disallow deprecated cds.sql.native_hana_associations: true configuration |
| cds-sql-runtime-view-mode | Disallow deprecated cds.sql.runtimeView.mode: "resolve" configuration |
| cds-sql-transitive-localized-views | Disallow deprecated cds.sql.transitive_localized_views: true configuration |
Configuration
Add the plugin to your ESLint configuration:
ESLint v9+ (Flat Config)
import json from "@eslint/json";
import capConfig from "eslint-plugin-better-cap-config";
export default [
{
files: ["**/*.json"],
plugins: {
json,
"cap-config": capConfig,
},
language: "json/json",
rules: {
"cap-config/cds-fiori-draft-compat": "error",
"cap-config/cds-features-odata-new-adapter": "error",
"cap-config/cds-features-cds-validate": "error",
},
},
];Using the Recommended Configuration
import { defineConfig } from "eslint/config";
import json from "@eslint/json";
import capConfig from "eslint-plugin-better-cap-config";
export default defineConfig([
{
files: ["**/*.json"],
plugins: {
json,
},
language: "json/json",
extends: [capConfig.configs.recommended],
},
]);Prerequisites
This plugin requires:
- ESLint v9.0.0 or higher
- Node.js v18.0.0 or higher
@eslint/jsonfor JSON language support
Supported Files
The plugin works with:
package.jsonfiles.cdsrc.jsonfiles- Any JSON files containing CDS configuration
Development
Building
pnpm buildTesting
pnpm test
pnpm test:watch
pnpm test:coverageLinting
pnpm lint
pnpm lint:fixLicense
MIT License
