lint: move rule docs and samples closer together (#2112) · mofterdinger/docs@d6a5a40 · GitHub
Skip to content

Commit d6a5a40

Browse files
authored
lint: move rule docs and samples closer together (capire#2112)
The current split into `rules/` and `examples/` folders is a bit hard to grasp. Move the sample and docs for a rule in one folder, eliminating the `examples` folder. URLs change slightly: - `cds-lint/rules/foobar` (before) - `cds-lint/rules/foobar/` (now)
1 parent bc1cb06 commit d6a5a40

104 files changed

Lines changed: 187 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/eslint-plugin/index.js

100644100755
Lines changed: 10 additions & 12 deletions

.github/eslint-plugin/js-rule-stub.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ status: released
33
---
44

55
<script setup>
6-
import PlaygroundBadge from '../components/PlaygroundBadge.vue'
6+
import PlaygroundBadge from '../../components/PlaygroundBadge.vue'
77
</script>
88

99
# $RULE_NAME
@@ -22,7 +22,7 @@ This rule was introduced in `@sap/eslint-plugin-cds x.y.z`.
2222
DESCRIPTION OF CORRECT EXAMPLE
2323

2424
::: code-group
25-
<<< ../examples/$RULE_NAME/correct/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
25+
<<< correct/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
2626
:::
2727
<PlaygroundBadge
2828
name="$RULE_NAME"
@@ -35,7 +35,7 @@ DESCRIPTION OF CORRECT EXAMPLE
3535
DESCRIPTION OF INCORRECT EXAMPLE
3636

3737
::: code-group
38-
<<< ../examples/$RULE_NAME/incorrect/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
38+
<<< incorrect/srv/admin-service.js#snippet{js:line-numbers} [srv/admin-service.js]
3939
:::
4040
<PlaygroundBadge
4141
name="$RULE_NAME"

tools/cds-lint/components/PlaygroundBadge.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Props {
1111
withDefaults(defineProps<Props>(), { nolink: false })
1212
import { compress, prettyStringify } from './eslint-online-playground/utils';
1313
// @ts-ignore
14-
import { data } from '../examples/examples.data.ts';
14+
import { data } from '../rules/examples.data.ts';
1515
1616
const configFileName = "eslint.config.js";
1717
const packageJsonFileName = "package.json";
@@ -29,7 +29,7 @@ export default [
2929
3030
const defaultPackageJson = JSON.parse(data['package.json']);
3131
32-
const is_object = x => typeof x === 'object' && x !== null && !Array.isArray(x)
32+
const is_object = (x:any) => typeof x === 'object' && x !== null && !Array.isArray(x)
3333
function merge (o:any,...xs:any) {
3434
let v:any; for (let x of xs) for (let k in x)
3535
if (k === '__proto__' || k === 'constructor') continue //> avoid prototype pollution

tools/cds-lint/examples/no-shared-handler-variable/correct/srv/admin-service.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

tools/cds-lint/examples/no-shared-handler-variable/incorrect/srv/admin-service.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

tools/cds-lint/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To turn on lint checking in your VS Code Editor simply download the [ESLint exte
5858
CDS Lint seamlessly integrates with it. For _SAP Business Application Studio_ this comes preinstalled.
5959

6060
Now you can see lint reports also in your editor. You can see all rules [marked as **Editor default** here](./rules/). Any other (project-based) rules are not turned on by
61-
default but can be turned on via the `show` rule option. For example, if we want to show the [`valid-csv-header`](./rules/valid-csv-header) rule reports in the Editor, we would add the following to our ESLint
61+
default but can be turned on via the `show` rule option. For example, if we want to show the [`valid-csv-header`](./rules/valid-csv-header/) rule reports in the Editor, we would add the following to our ESLint
6262
`rules` configuration:
6363

6464
```json

tools/cds-lint/rules/_menu.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# [assoc2many-ambiguous-key](assoc2many-ambiguous-key)
2-
# [auth-no-empty-restrictions](auth-no-empty-restrictions)
3-
# [auth-restrict-grant-service](auth-restrict-grant-service)
4-
# [auth-use-requires](auth-use-requires)
5-
# [auth-valid-restrict-grant](auth-valid-restrict-grant)
6-
# [auth-valid-restrict-keys](auth-valid-restrict-keys)
7-
# [auth-valid-restrict-to](auth-valid-restrict-to)
8-
# [auth-valid-restrict-where](auth-valid-restrict-where)
9-
# [case-sensitive-well-known-events](case-sensitive-well-known-events)
10-
# [extension-restrictions](extension-restrictions)
11-
# [latest-cds-version](latest-cds-version)
12-
# [no-cross-service-import](no-cross-service-import)
13-
# [no-db-keywords](no-db-keywords)
14-
# [no-deep-sap-cds-import](no-deep-sap-cds-import)
15-
# [no-dollar-prefixed-names](no-dollar-prefixed-names)
16-
# [no-java-keywords](no-java-keywords)
17-
# [no-join-on-draft](no-join-on-draft)
18-
# [no-shared-handler-variable](no-shared-handler-variable)
19-
# [sql-cast-suggestion](sql-cast-suggestion)
20-
# [sql-null-comparison](sql-null-comparison)
21-
# [start-elements-lowercase](start-elements-lowercase)
22-
# [start-entities-uppercase](start-entities-uppercase)
23-
# [use-cql-select-template-strings](use-cql-select-template-strings)
24-
# [valid-csv-header](valid-csv-header)
1+
# [assoc2many-ambiguous-key](assoc2many-ambiguous-key/)
2+
# [auth-no-empty-restrictions](auth-no-empty-restrictions/)
3+
# [auth-restrict-grant-service](auth-restrict-grant-service/)
4+
# [auth-use-requires](auth-use-requires/)
5+
# [auth-valid-restrict-grant](auth-valid-restrict-grant/)
6+
# [auth-valid-restrict-keys](auth-valid-restrict-keys/)
7+
# [auth-valid-restrict-to](auth-valid-restrict-to/)
8+
# [auth-valid-restrict-where](auth-valid-restrict-where/)
9+
# [case-sensitive-well-known-events](case-sensitive-well-known-events/)
10+
# [extension-restrictions](extension-restrictions/)
11+
# [latest-cds-version](latest-cds-version/)
12+
# [no-cross-service-import](no-cross-service-import/)
13+
# [no-db-keywords](no-db-keywords/)
14+
# [no-deep-sap-cds-import](no-deep-sap-cds-import/)
15+
# [no-dollar-prefixed-names](no-dollar-prefixed-names/)
16+
# [no-java-keywords](no-java-keywords/)
17+
# [no-join-on-draft](no-join-on-draft/)
18+
# [no-shared-handler-variable](no-shared-handler-variable/)
19+
# [sql-cast-suggestion](sql-cast-suggestion/)
20+
# [sql-null-comparison](sql-null-comparison/)
21+
# [start-elements-lowercase](start-elements-lowercase/)
22+
# [start-entities-uppercase](start-entities-uppercase/)
23+
# [use-cql-select-template-strings](use-cql-select-template-strings/)
24+
# [valid-csv-header](valid-csv-header/)

tools/cds-lint/examples/assoc2many-ambiguous-key/correct/db/schema.cds renamed to tools/cds-lint/rules/assoc2many-ambiguous-key/correct/db/schema.cds

File renamed without changes.

tools/cds-lint/examples/assoc2many-ambiguous-key/incorrect/db/schema.cds renamed to tools/cds-lint/rules/assoc2many-ambiguous-key/incorrect/db/schema.cds

File renamed without changes.

tools/cds-lint/rules/assoc2many-ambiguous-key.md renamed to tools/cds-lint/rules/assoc2many-ambiguous-key/index.md

Lines changed: 4 additions & 4 deletions

0 commit comments

Comments
 (0)