@studiometa/eslint-plugin-js-toolkit 0.1.0 → 3.6.0-beta.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 ADDED
@@ -0,0 +1,124 @@
1
+ # @studiometa/eslint-plugin-js-toolkit
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@studiometa/eslint-plugin-js-toolkit.svg?style=flat&colorB=3e63dd&colorA=414853)](https://www.npmjs.com/package/@studiometa/eslint-plugin-js-toolkit/)
4
+ [![Downloads](https://img.shields.io/npm/dm/@studiometa/eslint-plugin-js-toolkit?style=flat&colorB=3e63dd&colorA=414853)](https://www.npmjs.com/package/@studiometa/eslint-plugin-js-toolkit/)
5
+ [![Size](https://img.shields.io/bundlephobia/minzip/@studiometa/eslint-plugin-js-toolkit?style=flat&colorB=3e63dd&colorA=414853&label=size)](https://bundlephobia.com/package/@studiometa/js-toolkit)
6
+ [![Dependency Status](https://img.shields.io/librariesio/release/npm/eslint-plugin-js-toolkit?style=flat&colorB=3e63dd&colorA=414853)](https://david-dm.org/studiometa/js-toolkit)
7
+ ![Codecov](https://img.shields.io/codecov/c/github/studiometa/js-toolkit?style=flat&colorB=3e63dd&colorA=414853)
8
+
9
+ Oxlint/ESLint plugin enforcing best practices for [@studiometa/js-toolkit](https://js-toolkit.studiometa.dev).
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install --save-dev @studiometa/eslint-plugin-js-toolkit
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ### Oxlint
20
+
21
+ Add the plugin to your `.oxlintrc.json`:
22
+
23
+ ```json
24
+ {
25
+ "jsPlugins": [{ "name": "js-toolkit", "specifier": "@studiometa/eslint-plugin-js-toolkit" }],
26
+ "rules": {
27
+ "js-toolkit/require-config": "error",
28
+ "js-toolkit/require-config-name-pascal-case": "error",
29
+ "js-toolkit/refs-camel-case": "error",
30
+ "js-toolkit/refs-plural-multiple": "error",
31
+ "js-toolkit/options-camel-case": "error",
32
+ "js-toolkit/async-lifecycle-methods": "error",
33
+ "js-toolkit/on-handler-naming": "error",
34
+ "js-toolkit/on-global-handler-prefix": "warn",
35
+ "js-toolkit/no-deprecated-properties": "warn",
36
+ "js-toolkit/no-dispatch-event": "warn",
37
+ "js-toolkit/no-shadow-dom": "error",
38
+ "js-toolkit/no-create-app": "warn",
39
+ "js-toolkit/no-event-listener-methods": "error",
40
+ "js-toolkit/no-deep-utils-import": "error",
41
+ "js-toolkit/refs-no-bracket-access": "error",
42
+ "js-toolkit/no-redundant-with-mount-when-in-view": "warn",
43
+ "js-toolkit/prefer-ref-over-query-selector": "warn",
44
+ "js-toolkit/require-refs-declared-in-config": "error",
45
+ "js-toolkit/no-manual-intersection-observer": "warn",
46
+ "js-toolkit/no-manual-mutation-observer": "warn"
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### ESLint
52
+
53
+ Add the recommended config to your `eslint.config.js` (ESLint v9 flat config):
54
+
55
+ ```js
56
+ import jsToolkit from '@studiometa/eslint-plugin-js-toolkit';
57
+
58
+ export default [
59
+ jsToolkit.configs.recommended,
60
+ // ...your other config
61
+ ];
62
+ ```
63
+
64
+ To customise individual rule severities, add an override entry after the recommended config:
65
+
66
+ ```js
67
+ import jsToolkit from '@studiometa/eslint-plugin-js-toolkit';
68
+
69
+ export default [
70
+ jsToolkit.configs.recommended,
71
+ {
72
+ rules: {
73
+ 'js-toolkit/no-create-app': 'error', // override the default 'warn'
74
+ },
75
+ },
76
+ ];
77
+ ```
78
+
79
+ ## Rules
80
+
81
+ ### Class structure
82
+
83
+ | Rule | Description | Recommended | Fixable |
84
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------ | ----------- | ------- |
85
+ | `js-toolkit/require-config` | Requires a `static config` property with a `name` on every class extending `Base`. | error | |
86
+ | `js-toolkit/require-config-name-pascal-case` | Requires `config.name` to be PascalCase. | error | 🔧 |
87
+ | `js-toolkit/refs-camel-case` | Requires ref names in `config.refs` to be camelCase. Supports the `[]` multiple-ref suffix. | error | 🔧 |
88
+ | `js-toolkit/refs-plural-multiple` | Requires refs using the `[]` multiple-ref suffix to be pluralized (e.g. `links[]` not `link[]`). | error | |
89
+ | `js-toolkit/options-camel-case` | Requires option keys in `config.options` to be camelCase. | error | 🔧 |
90
+
91
+ ### Lifecycle methods
92
+
93
+ | Rule | Description | Recommended | Fixable |
94
+ | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- |
95
+ | `js-toolkit/async-lifecycle-methods` | Requires lifecycle methods (`mounted`, `destroyed`, `updated`, `terminated`, `ticked`, `scrolled`, `resized`, `moved`, `loaded`, `keyed`) to be declared `async`. | error | 🔧 |
96
+
97
+ ### Event handlers
98
+
99
+ | Rule | Description | Recommended | Fixable |
100
+ | ------------------------------------- | ------------------------------------------------------------------------------------------------------ | ----------- | ------- |
101
+ | `js-toolkit/on-handler-naming` | Requires event handler methods to follow the `onXxxYyy` camelCase convention. | error | |
102
+ | `js-toolkit/on-global-handler-prefix` | Requires handlers for window-only events (e.g. `resize`) to use the `onWindow` or `onDocument` prefix. | warn | |
103
+
104
+ ### Forbidden patterns
105
+
106
+ | Rule | Description | Recommended | Fixable |
107
+ | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- |
108
+ | `js-toolkit/no-deprecated-properties` | Disallows deprecated properties (`$parent`, `$root`, `$children`). Use `$closest()` or `$query()` instead. | warn | |
109
+ | `js-toolkit/no-dispatch-event` | Disallows `dispatchEvent()` inside `Base` subclasses. Use `this.$emit()` instead. | warn | |
110
+ | `js-toolkit/no-shadow-dom` | Disallows `attachShadow()` inside `Base` subclasses. The framework uses Light DOM only. | error | |
111
+ | `js-toolkit/no-create-app` | Disallows `createApp()` (deprecated). Use `registerComponent()` instead. | warn | |
112
+ | `js-toolkit/no-event-listener-methods` | Disallows `addEventListener()` and `removeEventListener()` inside `Base` subclasses. Define `on*` methods instead — the framework handles binding and cleanup automatically. | error | |
113
+ | `js-toolkit/no-deep-utils-import` | Disallows deep imports from `@studiometa/js-toolkit/utils/*`. Use the public entrypoint `@studiometa/js-toolkit/utils` instead. | error | 🔧 |
114
+ | `js-toolkit/no-redundant-with-mount-when-in-view` | Disallows wrapping `withMountWhenInView` inside `withScrolledInView` — the latter already includes the former internally. | warn | |
115
+ | `js-toolkit/no-manual-intersection-observer` | Disallows `new IntersectionObserver()` inside `Base` subclasses. Use `withIntersectionObserver` or `withMountWhenInView` decorators instead. | warn | |
116
+ | `js-toolkit/no-manual-mutation-observer` | Disallows `new MutationObserver()` inside `Base` subclasses. Use the `withMutation` decorator instead. | warn | |
117
+
118
+ ### Refs
119
+
120
+ | Rule | Description | Recommended | Fixable |
121
+ | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- |
122
+ | `js-toolkit/refs-no-bracket-access` | Disallows bracket access with a `[]` suffix on `this.$refs` (e.g. `this.$refs['items[]']`). Rewrites to dot notation camelCase. | error | 🔧 |
123
+ | `js-toolkit/prefer-ref-over-query-selector` | Warns when `this.$el.querySelector()` or `this.$el.querySelectorAll()` is used inside a `Base` subclass. Declare a ref in `static config` and use `this.$refs` instead. | warn | |
124
+ | `js-toolkit/require-refs-declared-in-config` | Requires all `this.$refs.<name>` accesses to be declared in `static config.refs`. | error | |
@@ -0,0 +1,4 @@
1
+ declare const plugin: import("@oxlint/plugins").Plugin & {
2
+ configs: Record<string, object>;
3
+ };
4
+ export default plugin;