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
Ifacustomprocessornamestartswith`.`, ESLinthandlestheprocessorasa **fileextension-namedprocessor**. ESLintappliestheprocessortofileswiththatfilenameextensionautomatically. Usersdon't need to specify the file extension-named processors in their config files.
Copy file name to clipboardExpand all lines: docs/src/extend/plugins.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,10 @@ Plugin environments can define the following objects:
89
89
90
90
### Processors in Plugins
91
91
92
+
::: warning
93
+
File extension-named processors are deprecated and only work in eslintrc-style configuration files. Flat config files do not automatically apply processors; you need to explicitly set the `processor` property.
94
+
:::
95
+
92
96
You can add processors to plugins by including the processor functions in the `processors` key. For more information on defining custom processors, refer to [Custom Processors](custom-processors).
Copy file name to clipboardExpand all lines: docs/src/use/configure/migration-guide.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,83 @@ export default [
114
114
];
115
115
```
116
116
117
+
### Processors
118
+
119
+
In eslintrc files, processors had to be defined in a plugin, and then referenced by name in the configuration. Processors beginning with a dot indicated a [file extension-named processor](../../extend/custom-processors#file-extension-named-processor) which ESLint would automatically configure for that file extension.
120
+
121
+
In flat config files, processors can still be referenced from plugins by their name, but they can now also be inserted directly into the configuration. Processors will _never_ be automatically configured, and must be explicitly set in the configuration.
122
+
123
+
As an example with a custom plugin with processors:
124
+
125
+
```javascript
126
+
// node_modules/eslint-plugin-someplugin/index.js
127
+
module.exports= {
128
+
processors: {
129
+
".md": {
130
+
preprocess() {},
131
+
postprocess() {}
132
+
},
133
+
"someProcessor": {
134
+
preprocess() {},
135
+
postprocess() {}
136
+
}
137
+
}
138
+
};
139
+
```
140
+
141
+
In eslintrc, you would configure as follows:
142
+
143
+
```javascript
144
+
// .eslintrc.js
145
+
module.exports= {
146
+
plugins: ["someplugin"],
147
+
processor:"someplugin/someProcessor"
148
+
};
149
+
```
150
+
151
+
ESLint would also automatically add the equivalent of the following:
152
+
153
+
```javascript
154
+
{
155
+
overrides: [{
156
+
files: ["**/*.md"],
157
+
processor:"someplugin/.md"
158
+
}]
159
+
}
160
+
```
161
+
162
+
In flat config, the following are all valid ways to express the same:
163
+
164
+
```javascript
165
+
// eslint.config.js
166
+
importsomePluginfrom"eslint-plugin-someplugin";
167
+
168
+
exportdefault [
169
+
{
170
+
plugins: { somePlugin },
171
+
processor:"somePlugin/someProcessor"
172
+
},
173
+
{
174
+
plugins: { somePlugin },
175
+
// We can embed the processor object in the config directly
176
+
processor:somePlugin.processors.someProcessor
177
+
},
178
+
{
179
+
// We don't need the plugin to be present in the config to use the processor directly
180
+
processor:somePlugin.processors.someProcessor
181
+
}
182
+
];
183
+
```
184
+
185
+
Note that because the `.md` processor is _not_ automatically added by flat config, you also need to specify an extra configuration element:
186
+
187
+
```javascript
188
+
{
189
+
files: ["**/*.md"],
190
+
processor:somePlugin.processors[".md"]
191
+
}
192
+
```
193
+
117
194
### Glob-Based Configs
118
195
119
196
By default, eslintrc files lint all files (except those covered by `.eslintignore`) in the directory in which they’re placed and its child directories. If you want to have different configurations for different file glob patterns, you can specify them in the `overrides` property.
0 commit comments