Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hildjj committed Feb 19, 2024
1 parent 980ccaf commit 3cf3359
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 20 deletions.
3 changes: 2 additions & 1 deletion docs/rules/camelCase.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/camelCase

> Rule names should be UpperCamelCase and label names should be lowerCamelCase.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix many, but not all errors.
Expand Down Expand Up @@ -44,4 +45,4 @@ _ = [ \t]
## 🔎 Implementation

- [Rule source](../../src/rules/camelCase.ts)
- [Test source](../../test/lib/rules/camelCase.js)
- [Test source](../../test/rules/camelCase.test.js)
3 changes: 2 additions & 1 deletion docs/rules/equal-next-line.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/equal-next-line

> Ensure that the equals sign in a rule is in a consistent location.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -87,4 +88,4 @@ See [Settings](../settings.md).
## 🔎 Implementation

- [Rule source](../../src/rules/equal-next-line.ts)
- [Test source](../../test/lib/rules/equal-next-line.js)
- [Test source](../../test/rules/equal-next-line.test.js)
3 changes: 2 additions & 1 deletion docs/rules/no-empty-code-blocks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/no-empty-code-blocks

> Code blocks should not be empty.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -43,4 +44,4 @@ bar = !{ return false; } "1"
## 🔎 Implementation

- [Rule source](../../src/rules/no-empty-code-blocks.ts)
- [Test source](../../test/lib/rules/no-empty-code-blocks.js)
- [Test source](../../test/rules/no-empty-code-blocks.test.js)
3 changes: 2 additions & 1 deletion docs/rules/no-empty-initializers.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/no-empty-initializers

> Top-level and per-instance initializers should not be empty.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -55,4 +56,4 @@ foo = "1" { return loc({ type: "foo" }); }
## 🔎 Implementation

- [Rule source](../../src/rules/no-empty-initializers.ts)
- [Test source](../../test/lib/rules/no-empty-initializers.js)
- [Test source](../../test/rules/no-empty-initializers.test.js)
3 changes: 2 additions & 1 deletion docs/rules/no-unused-labels.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/no-unused-rules

> Labels may not be used without either an action or a semantic predicate to
> reference them.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
Expand Down Expand Up @@ -34,4 +35,4 @@ bar = n:"1" &{ return n === "1"; }
## 🔎 Implementation

- [Rule source](../../src/rules/no-unused-labels.ts)
- [Test source](../../test/lib/rules/no-unused-labels.js)
- [Test source](../../test/rules/no-unused-labels.test.js)
9 changes: 5 additions & 4 deletions docs/rules/no-unused-rules.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/no-unused-rules

> All rules except for the first one must be referenced by another rule.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
Expand All @@ -12,7 +13,7 @@ might be caused by typos, or they may be left over from previous versions.

```peg.js
// eslint @peggyjs/no-unused-rules

import baz from "./baz.js" // Bad. Not referenced.
foo = "1" // Good. Default entry point.
bar = "2" // Bad. Not referenced.
```
Expand All @@ -21,12 +22,12 @@ bar = "2" // Bad. Not referenced.

```peg.js
// eslint @peggyjs/no-unused-rules

foo = bar
import baz from "./baz.js"
foo = bar / baz
bar = "2"
```

## 🔎 Implementation

- [Rule source](../../src/rules/no-unused-rules.ts)
- [Test source](../../test/lib/rules/no-unused-rules.js)
- [Test source](../../test/rules/no-unused-rules.test.js)
7 changes: 4 additions & 3 deletions docs/rules/quotes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/quotes

> Enforce the consistent use of double or single quotes.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -26,8 +27,8 @@ Foo 'Frequently Observed Ocelot' = "bar"

```peg.js
// eslint @peggyjs/quotes: ["error", "double"]

Foo "More Ocelots" = "bar"
import {"boo" as bar} from "bar.js"
Foo "More Ocelots" = "bar" / boo
```

```peg.js
Expand Down Expand Up @@ -67,4 +68,4 @@ there are no exceptions.
## 🔎 Implementation

- [Rule source](../../src/rules/quotes.ts)
- [Test source](../../test/lib/rules/quotes.js)
- [Test source](../../test/rules/quotes.test.js)
3 changes: 2 additions & 1 deletion docs/rules/rule-order.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/rule-order

> Rule definitions should come after all references to that rule, unless there
> is a rule loop.
Expand Down Expand Up @@ -36,4 +37,4 @@ Boo = Foo // Loop ok
## 🔎 Implementation

- [Rule source](../../src/rules/rule-order.ts)
- [Test source](../../test/lib/rules/rule-order.js)
- [Test source](../../test/rules/rule-order.test.js)
3 changes: 2 additions & 1 deletion docs/rules/semantic-predicate-must-return.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/semantic-predicate-must-return

> Top-level and per-instance initializers should not be empty.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
Expand Down Expand Up @@ -40,4 +41,4 @@ foo = n:"1" !{ return n === "2"; }
## 🔎 Implementation

- [Rule source](../../src/rules/semantic-predicate-must-return.ts)
- [Test source](../../test/lib/rules/semantic-predicate-must-return.js)
- [Test source](../../test/rules/semantic-predicate-must-return.test.js)
5 changes: 3 additions & 2 deletions docs/rules/semi.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/semi

> Enforce consistent use of semicolons
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix errors.
Expand Down Expand Up @@ -42,5 +43,5 @@ foo = "bar"

## 🔎 Implementation

- [Rule source](../../src/rules/camelCase.ts)
- [Test source](../../test/lib/rules/camelCase.js)
- [Rule source](../../src/rules/semi.ts)
- [Test source](../../test/rules/semi.test.js)
3 changes: 2 additions & 1 deletion docs/rules/separate-choices.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/separate-choices

> Ensure that each top-level choice in a rule is on a new line.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -33,4 +34,4 @@ See [Settings](../settings.md).
## 🔎 Implementation

- [Rule source](../../src/rules/separate-choices.ts)
- [Test source](../../test/lib/rules/separate-choices.js)
- [Test source](../../test/rules/separate-choices.test.js)
3 changes: 2 additions & 1 deletion docs/rules/space-ops.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @peggyjs/space-ops

> Consistent spacing around operators and other punctuation.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
> - ✒️ This rule will fix all errors it finds.
Expand Down Expand Up @@ -66,4 +67,4 @@ The value is a number (see above for meaning).
## 🔎 Implementation

- [Rule source](../../src/rules/space-ops.ts)
- [Test source](../../test/lib/rules/space-ops.js)
- [Test source](../../test/rules/space-ops.test.js)
38 changes: 38 additions & 0 deletions docs/rules/valid-imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @peggyjs/valid-imports

> All imports must point to correct JS files, compiled by Peggy 4.0.0 or later,
> which export the expected rule name as an allowedStartRule.
> - ⭐️ This rule is included in `plugin:@peggyjs/recommended` preset.
## 📖 Rule Details

This rule does a spot-check to see if a module that is imported with a set
of library rules will work. It does NOT load the module with the node loader,
but it does read the file and ensure that:

- The file exists
- It looks like it is a Peggy parser
- It was compiled by a recent-enough version of Peggy that it can be used
for library calls
- It was compiled with the correct rules marked as allowedStartRules

:-1: Examples of **incorrect** code for this rule:

```peg.js
// eslint @peggyjs/valid-imports: "error"
import * as bar from "NO_SUCH_FILE.js"
Bar = bar.boo
```

:+1: Examples of **correct** code for this rule:

```peg.js
// eslint @peggyjs/valid-imports: "error"
import {"foo" as bar} from "./bar.js"
foo = bar
```

## 🔎 Implementation

- [Rule source](../../src/rules/valid-imports.ts)
- [Test source](../../test/rules/valid-imports.test.js)
2 changes: 1 addition & 1 deletion lib/rules/valid-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const rule = {
meta: {
type: "problem",
docs: {
description: "Ensure imports point to valid js files that have the right format and export the expected rules.",
description: "All imports must point to correct JS files, compiled by Peggy 4.0.0 or later, which export the expected rule name as an allowedStartRule.",
recommended: true,
url: "https://github.com/peggyjs/peggyjs-eslint-plugin/blob/main/docs/rules/valid-imports.md",
},
Expand Down
2 changes: 1 addition & 1 deletion src/rules/valid-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const rule: Rule.RuleModule = {
meta: {
type: "problem",
docs: {
description: "Ensure imports point to valid js files that have the right format and export the expected rules.",
description: "All imports must point to correct JS files, compiled by Peggy 4.0.0 or later, which export the expected rule name as an allowedStartRule.",
recommended: true,
url: "https://github.com/peggyjs/peggyjs-eslint-plugin/blob/main/docs/rules/valid-imports.md",
},
Expand Down

0 comments on commit 3cf3359

Please sign in to comment.