Skip to content

Commit 7fb4208

Browse files
authored
linter: replace plop with xtask new-rule (#452)
1 parent 736984a commit 7fb4208

File tree

16 files changed

+302
-1403
lines changed

16 files changed

+302
-1403
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ See [the README's dev section](./README.md#dev) for development information.
1010

1111
## Adding new rules
1212

13-
When adding a new rule, the `s/new-rule` script will create stubs for your rule in Rust and in Documentation site.
13+
When adding a new rule, running `cargo xtask new-rule` will create stubs for your rule in the Rust crate and in Documentation site.
1414

1515
```bash
16-
s/new-rule 'prefer big serial'
16+
cargo xtask new-rule 'prefer big serial'
1717
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ $ nix develop
276276
277277
### Adding a New Rule
278278
279-
When adding a new rule, the `s/new-rule` script will create stubs for your rule in Rust and in Documentation site.
279+
When adding a new rule, running `cargo xtask new-rule` will create stubs for your rule in the Rust crate and in Documentation site.
280280
281281
```bash
282-
s/new-rule 'prefer big serial'
282+
cargo xtask new-rule 'prefer big serial'
283283
```
284284
285285
### Releasing a New Version

crates/squawk_linter/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use rules::renaming_table;
4848
use rules::require_concurrent_index_creation;
4949
use rules::require_concurrent_index_deletion;
5050
use rules::transaction_nesting;
51-
// xtask:new-lint:rule-import
51+
// xtask:new-rule:rule-import
5252

5353
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Hash, Eq, Deserialize, Sequence)]
5454
pub enum Rule {
@@ -108,7 +108,7 @@ pub enum Rule {
108108
BanCreateDomainWithConstraint,
109109
#[serde(rename = "ban-alter-domain-with-add-constraint")]
110110
BanAlterDomainWithAddConstraint,
111-
// xtask:new-lint:error-name
111+
// xtask:new-rule:error-name
112112
}
113113

114114
impl TryFrom<&str> for Rule {
@@ -145,7 +145,7 @@ impl TryFrom<&str> for Rule {
145145
}
146146
"ban-create-domain-with-constraint" => Ok(Rule::BanCreateDomainWithConstraint),
147147
"ban-alter-domain-with-add-constraint" => Ok(Rule::BanAlterDomainWithAddConstraint),
148-
// xtask:new-lint:str-name
148+
// xtask:new-rule:str-name
149149
_ => Err(format!("Unknown violation name: {}", s)),
150150
}
151151
}
@@ -202,6 +202,7 @@ impl fmt::Display for Rule {
202202
Rule::BanCreateDomainWithConstraint => "ban-create-domain-with-constraint",
203203
Rule::UnusedIgnore => "unused-ignore",
204204
Rule::BanAlterDomainWithAddConstraint => "ban-alter-domain-with-add-constraint",
205+
// xtask:new-rule:variant-to-name
205206
};
206207
write!(f, "{}", val)
207208
}
@@ -344,7 +345,7 @@ impl Linter {
344345
if self.rules.contains(&Rule::TransactionNesting) {
345346
transaction_nesting(self, &file);
346347
}
347-
// xtask:new-lint:rule-call
348+
// xtask:new-rule:rule-call
348349

349350
// locate any ignores in the file
350351
find_ignores(self, &file.syntax_node());

crates/squawk_linter/src/rules/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) mod renaming_table;
2525
pub(crate) mod require_concurrent_index_creation;
2626
pub(crate) mod require_concurrent_index_deletion;
2727
pub(crate) mod transaction_nesting;
28-
// xtask:new-lint:mod-decl
28+
// xtask:new-rule:mod-decl
2929

3030
pub(crate) use adding_field_with_default::adding_field_with_default;
3131
pub(crate) use adding_foreign_key_constraint::adding_foreign_key_constraint;
@@ -54,4 +54,4 @@ pub(crate) use renaming_table::renaming_table;
5454
pub(crate) use require_concurrent_index_creation::require_concurrent_index_creation;
5555
pub(crate) use require_concurrent_index_deletion::require_concurrent_index_deletion;
5656
pub(crate) use transaction_nesting::transaction_nesting;
57-
// xtask:new-lint:export
57+
// xtask:new-rule:export

crates/xtask/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use anyhow::Result;
22
// see: https://github.com/matklad/cargo-xtask
33
use clap::{arg, Args, Parser, Subcommand};
44
use generate_keywords::generate_keywords;
5-
use new_lint::new_lint;
5+
use new_rule::new_lint;
66
use sync_kwlist::sync_kwlist;
77

88
mod generate_keywords;
9-
mod new_lint;
9+
mod new_rule;
1010
mod path_util;
1111
mod sync_kwlist;
1212

@@ -17,11 +17,11 @@ enum TaskName {
1717
#[command(long_about = "Fetch the latest version of kwlist.h from Postgres")]
1818
SyncKwlist,
1919
#[command(long_about = "Create a new linter rule")]
20-
NewLint(NewLintArgs),
20+
NewRule(NewRuleArgs),
2121
}
2222

2323
#[derive(Args, Debug)]
24-
struct NewLintArgs {
24+
struct NewRuleArgs {
2525
#[arg(required = true)]
2626
name: String,
2727
}
@@ -39,6 +39,6 @@ fn main() -> Result<()> {
3939
match args.task {
4040
TaskName::GenerateKeywords => generate_keywords(),
4141
TaskName::SyncKwlist => sync_kwlist(),
42-
TaskName::NewLint(args) => new_lint(args),
42+
TaskName::NewRule(args) => new_lint(args),
4343
}
4444
}

crates/xtask/src/new_lint.rs

Lines changed: 0 additions & 202 deletions
This file was deleted.

0 commit comments

Comments
 (0)