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
Copy file name to clipboardExpand all lines: text/3389-manifest-lint.md
+57-47Lines changed: 57 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,8 @@ However, we also need to consider how decisions might limit us in the future and
206
206
- Whether existing decisions will be revisited
207
207
- When new tools are added, like `cargo` and `cargo-semver-check`, which haven't had lint levels and configuration long enough (or at all) to explore their problem and design space.
208
208
209
+
## Misc
210
+
209
211
This could be left to `clippy.toml` but that leaves `rustc`, `rustdoc`, and future linters without a solution.
210
212
211
213
`[lints]` could be `[package.lints]`, tying it to the package unlike `[patch]`
@@ -214,41 +216,7 @@ and other fields that are more workspace related. Instead, we used
214
216
215
217
`[lints]` could be `[lint]` but we decided to follow the precedence of `[dependencies]`.
216
218
217
-
Instead of `<tool>.<lint>`, we could use `<tool>::<lint>` (e.g.
218
-
`"clipp::enum_glob_use"` instead of `clippy.enum_glob_use`), like in the
219
-
diagnostic messages. This would make it easier to copy/paste lint names.
220
-
However, with the schema being `<lint> = <level>`, this would require quoting
221
-
the keys rather than leaving them as bare words. This might also cause
222
-
problems for tool-level configuration. The first is that the lints wouldn't be
223
-
easily grouped with their tool's config. The second is if we use `lints.<lint> = <level>`
224
-
and tool-level configuration goes under `lints.<tool>`,
225
-
then keys under `[lints]` are ambiguous as to whether they are a tool or a
226
-
lint, making it harder to collect all lints to forward tools.
227
-
228
-
We could possibly extend this new field to `rustfmt` by shifting the focus from
229
-
"lints" to "rules" (see
230
-
[eslint](https://eslint.org/docs/latest/use/configure/rules)). However, the
231
-
more we generalize this field, the fewer assumptions we can make about it. On
232
-
one extreme is `package.metadata` which is so free-form we can't support it
233
-
with workspace inheritance. A less extreme example is if we make the
234
-
configuration too general, we would preclude the option of supporting
235
-
per-package overrides as we wouldn't know enough about the shape of the data to
236
-
know how to merge it. There is likely a middle ground that we could make work
237
-
but it would take time and experimentation to figure that out which is at odds
238
-
with trying to maintain a stable file format. Another problem with `rules` is
239
-
that it is divorced from any context. In eslint, it is in an eslint-specific
240
-
config file but a `[rules]` table is not a clear as a `[lints]` table as to
241
-
what role it fulfills.
242
-
243
-
We could support platform or feature specific settings, like with
244
-
`[lints.<target>]` or `[target.<target>.lints]` but
245
-
- There isn't a defined use case for this yet besides having support for `cfg(feature = "clippy")` or
246
-
which does not seem high enough priority to design
247
-
around.
248
-
-`[lints.<target>]` runs into ambiguity issues around what is a `<target>`
249
-
entry vs a `<lint>` entry in the `[lints]` table.
250
-
- We have not yet defined semantics for sharing something like this across a
251
-
workspace
219
+
## Schema
252
220
253
221
Instead of the `[lints]` table being `lint = "level"`, we could organize
254
222
it around `level = ["lint", ...]` like some other linters do (like
@@ -265,19 +233,18 @@ chose `lint` being the keys because
265
233
better maps to a users model to just say the package lint table gets merged
266
234
into the workspace lint table. This is also easier to implement correctly.
267
235
268
-
## Workspace Inheritance
236
+
## Linter Tables vs Linter Namespaces
269
237
270
-
Instead of using workspace inheritance for `[lint]`, we could make it
271
-
workspace-level configuration, like `[patch]` which is automatically applied to
272
-
all workspace members. However, `[patch]` and friends are because they affect
273
-
the resolver / `Cargo.toml` and so they can only operate at the workspace
274
-
level. `[lints]` is more like `[dependencies]` in being something that applies
275
-
at the package level but we want shared across workspaces.
276
-
277
-
Instead of traditional workspace inheritance where there is a single value to
278
-
inherit with `workspace = true`, we could have `[workspace.lints.<preset>]`
279
-
which defines presets and the user could do `lints.<preset> = true`. The user
280
-
could then name them as they wish to avoid collision with rustc lints.
238
+
Instead of `<tool>.<lint>`, we could use `<tool>::<lint>` (e.g.
239
+
`"clipp::enum_glob_use"` instead of `clippy.enum_glob_use`), like in the
240
+
diagnostic messages. This would make it easier to copy/paste lint names.
241
+
However, with the schema being `<lint> = <level>`, this would require quoting
242
+
the keys rather than leaving them as bare words. This might also cause
243
+
problems for tool-level configuration. The first is that the lints wouldn't be
244
+
easily grouped with their tool's config. The second is if we use `lints.<lint> = <level>`
245
+
and tool-level configuration goes under `lints.<tool>`,
246
+
then keys under `[lints]` are ambiguous as to whether they are a tool or a
247
+
lint, making it harder to collect all lints to forward tools.
281
248
282
249
## Lint Precedence
283
250
@@ -330,6 +297,49 @@ Where the order is based on how to pass them on the command-line.
330
297
Complex TOML arrays tend to be less friendly to work with including the fact
331
298
that TOML 1.0 does not allow multi-line inline tables.
332
299
300
+
## Workspace Inheritance
301
+
302
+
Instead of using workspace inheritance for `[lint]`, we could make it
303
+
workspace-level configuration, like `[patch]` which is automatically applied to
304
+
all workspace members. However, `[patch]` and friends are because they affect
305
+
the resolver / `Cargo.toml` and so they can only operate at the workspace
306
+
level. `[lints]` is more like `[dependencies]` in being something that applies
307
+
at the package level but we want shared across workspaces.
308
+
309
+
Instead of traditional workspace inheritance where there is a single value to
310
+
inherit with `workspace = true`, we could have `[workspace.lints.<preset>]`
311
+
which defines presets and the user could do `lints.<preset> = true`. The user
312
+
could then name them as they wish to avoid collision with rustc lints.
313
+
314
+
## `rustfmt`
315
+
316
+
We could possibly extend this new field to `rustfmt` by shifting the focus from
317
+
"lints" to "rules" (see
318
+
[eslint](https://eslint.org/docs/latest/use/configure/rules)). However, the
319
+
more we generalize this field, the fewer assumptions we can make about it. On
320
+
one extreme is `package.metadata` which is so free-form we can't support it
321
+
with workspace inheritance. A less extreme example is if we make the
322
+
configuration too general, we would preclude the option of supporting
323
+
per-package overrides as we wouldn't know enough about the shape of the data to
324
+
know how to merge it. There is likely a middle ground that we could make work
325
+
but it would take time and experimentation to figure that out which is at odds
326
+
with trying to maintain a stable file format. Another problem with `rules` is
327
+
that it is divorced from any context. In eslint, it is in an eslint-specific
328
+
config file but a `[rules]` table is not a clear as a `[lints]` table as to
329
+
what role it fulfills.
330
+
331
+
## Target-specific lint
332
+
333
+
We could support platform or feature specific settings, like with
334
+
`[lints.<target>]` or `[target.<target>.lints]` but
335
+
- There isn't a defined use case for this yet besides having support for `cfg(feature = "clippy")` or
336
+
which does not seem high enough priority to design
337
+
around.
338
+
-`[lints.<target>]` runs into ambiguity issues around what is a `<target>`
339
+
entry vs a `<lint>` entry in the `[lints]` table.
340
+
- We have not yet defined semantics for sharing something like this across a
0 commit comments