You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 97431f8
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/src/extend/custom-rules.md
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -991,13 +991,39 @@ While you can give a custom rule any name you'd like, the core rules have naming
991
991
992
992
## Runtime Rules
993
993
994
-
The thing that makes ESLint different from other linters is the ability to define custom rules at runtime. This is perfect for rules that are specific to your project or company and wouldn't make sense for ESLint to ship with or be included in a plugin. Just write your rules and include them at runtime.
994
+
You can include custom rules directly in your configuration file. This is perfect for rules that are specific to your project or company and that wouldn't make sense to ship with ESLint or to publish as a plugin.
995
995
996
-
Runtime rules are written in the same format as all other rules. Create your rule as you would any other and then follow these steps:
996
+
These rules are written in the same format as all other rules. Create your rule as you would any other and then follow these steps:
997
997
998
-
1. Place all of your runtime rules in the same directory (e.g., `eslint_rules`).
999
-
2. Create a [configuration file](../use/configure/) and specify your rule ID error level under the `rules` key. Your rule will not run unless it has a value of `"warn"` or `"error"` in the configuration file.
1000
-
3. Run the [command line interface](../use/command-line-interface) using the `--rulesdir` option to specify the location of your runtime rules.
998
+
1. Import your rule into your [configuration file](../use/configure/configuration-files#configuration-file).
999
+
2. Define a [virtual plugin](../use/configure/plugins#configure-a-virtual-plugin) under the `plugins` key and add your rule to its `rules` object.
1000
+
3. Specify the severity for your rule under the `rules` key, using the plugin namespace as a prefix for the rule ID (for example, `local/my-rule`). Your rule will not run unless its severity is `"warn"` or `"error"`.
1001
+
1002
+
For example, if your rule is in `rules/my-rule.js`, your configuration file would look like this:
0 commit comments