-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(require-name): add require-name rule
- Loading branch information
1 parent
8364668
commit a24436a
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# require-name | ||
|
||
💼 This rule is enabled in the ✅ `recommended` config. | ||
|
||
<!-- end auto-generated rule header --> | ||
|
||
This rule checks for the existence of the `"name"` property in a package.json, | ||
and reports a violation if it doesn't exist. | ||
|
||
Example of **incorrect** code for this rule: | ||
|
||
```json | ||
{ | ||
"version": "13.0.0", | ||
"author": "Jessica Moss" | ||
} | ||
``` | ||
|
||
Example of **correct** code for this rule: | ||
|
||
```json | ||
{ | ||
"name": "thee-silver-mt-zion", | ||
"version": "13.0.0", | ||
"author": "Jessica Moss" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { rules } from "../../rules/require-properties.js"; | ||
import { ruleTester } from "./ruleTester.js"; | ||
|
||
ruleTester.run("require-name", rules["require-name"], { | ||
invalid: [ | ||
{ | ||
code: "{}", | ||
errors: [ | ||
{ | ||
data: { property: "name" }, | ||
line: 1, | ||
messageId: "missing", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `{ | ||
"version": "1.0.0" | ||
} | ||
`, | ||
errors: [ | ||
{ | ||
data: { property: "name" }, | ||
line: 1, | ||
messageId: "missing", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `{ | ||
"author": "Jessica Moss", | ||
"bin": { | ||
"name": "test" | ||
} | ||
} | ||
`, | ||
errors: [ | ||
{ | ||
data: { property: "name" }, | ||
line: 1, | ||
messageId: "missing", | ||
}, | ||
], | ||
}, | ||
], | ||
valid: [`{ "name": "test" }`], | ||
}); |