@drupal-canvas/eslint-config 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/dist/index.js +3806 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Drupal Canvas ESLint Config
|
|
2
|
+
|
|
3
|
+
ESLint config for validating Drupal Canvas Code Components.
|
|
4
|
+
|
|
5
|
+
## Config variants
|
|
6
|
+
|
|
7
|
+
| Config | Description |
|
|
8
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `required` | Base settings for parsing JS/JSX files, YAML parsing for `component.yml` files, and custom rules for Drupal Canvas Code Component validation. Automatically used by [`@drupal-canvas/cli`](https://www.npmjs.com/package/@drupal-canvas/cli) when validating, building, or uploading components. |
|
|
10
|
+
| `recommended` | `required` + recommended rules from [`@eslint/js`](https://www.npmjs.com/package/@eslint/js), [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), [`eslint-plugin-jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y), and [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml). |
|
|
11
|
+
| `strict` | `recommended` + strict rules from [`eslint-plugin-jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y). |
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -D @drupal-canvas/eslint-config
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// eslint.config.js
|
|
21
|
+
import { recommended as drupalCanvasRecommended } from "@drupal-canvas/eslint-config";
|
|
22
|
+
import { defineConfig } from "eslint/config";
|
|
23
|
+
|
|
24
|
+
export default defineConfig([
|
|
25
|
+
...drupalCanvasRecommended,
|
|
26
|
+
// ...
|
|
27
|
+
]);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
The following custom rules are part of the `required` config and validate Drupal
|
|
33
|
+
Canvas Code Components:
|
|
34
|
+
|
|
35
|
+
| Rule | Description |
|
|
36
|
+
| ------------------------ | ----------------------------------------------------------------------------------------- |
|
|
37
|
+
| `component-dir-name` | Validates that component directory name matches the `machineName` in component.yml. |
|
|
38
|
+
| `component-exports` | Validates that component has a default export. |
|
|
39
|
+
| `component-files` | Validates that component directory contains only allowed files. |
|
|
40
|
+
| `component-imports` | Validates that component imports only from supported import sources and patterns. |
|
|
41
|
+
| `component-no-hierarchy` | Validates that all component directories are at the same level with no nesting hierarchy. |
|
|
42
|
+
| `component-prop-names` | Validates that component prop IDs match the camelCase version of their titles. |
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
The following scripts are available for developing this package:
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
| ------------ | ------------------------------------------------------------------------ |
|
|
50
|
+
| `dev` | Compile to the `dist` folder for development while watching for changes. |
|
|
51
|
+
| `build` | Compile to the `dist` folder for production use. |
|
|
52
|
+
| `type-check` | Run TypeScript type checking without emitting files. |
|
|
53
|
+
| `test` | Run tests. |
|