Skip to content

Commit 93002a5

Browse files
authored
docs: rework forbid-enum-md (tomalaforge#886)
1 parent 2002a6a commit 93002a5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
---
22
title: 🟢 Custom Eslint Rule
3-
description: Challenge 27 is about creating a custom Eslint Rule to forbid enums
3+
description: Challenge 27 is about creating a custom ESLint Rule to forbid enums
44
author: thomas-laforge
55
contributors:
66
- tomalaforge
7+
- jdegand
78
challengeNumber: 27
89
sidebar:
910
order: 12
1011
---
1112

1213
## Information
1314

14-
Eslint is an amazing tool that helps developers avoid simple mistakes and adhere to company style guides.
15+
ESLint is an amazing tool that helps developers avoid simple mistakes and adhere to company style guides.
1516

16-
In this first example, we will create a rule that forbids the use of enums. The rule will suggest using string unions instead of enums whenever you add an enum to your code. It is a straightforward rule for learning how to create rules.
17+
In this first example, we will create a rule that forbids the use of enums. The rule will suggest using string unions instead of enums whenever an enum is present in this repo's code. This is a straightforward rule for learning how to create rules.
1718

1819
You will also need to write tests to verify the rule's functionality.
1920

20-
To test the rule inside your project, add `"@nrwl/nx/workspace/forbidden-enum": "error"` to the `eslintrc.json` file and attempt to insert an enum into any project to witness the magic. 😇
21+
The `tools/eslint-rules` folder contains the starter code for this challenge.
2122

22-
To assist you with AST (Abstract Syntax Tree) definitions, you can visit the [AST explorer](https://astexplorer.net/) and use JavaScript, @typescript-eslint/parser, and Eslint-v8 as the transformation method. However, please note that you will only get the type information there. The transformation function may not work for TypeScript types since the editor is in JavaScript.
23+
To test the rule inside your project, add `"@nrwl/nx/workspace/forbidden-enum": "error"` to the `eslintrc.json`. You can navigate to Challenge 47, `Enums vs. Union Types', and you should immediately see an error.
2324

24-
You can also check this [repo](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/rules) for eslint rule examples.
25+
To assist you with AST (Abstract Syntax Tree) definitions, you can visit the [AST Explorer](https://astexplorer.net/) and use `JavaScript`, `@typescript-eslint/parser`, and `ESLint-v8` as the transformation methods. However, please note that you will only get the `type` information there. The transformation function may not work for TypeScript types since the editor is in JavaScript.
26+
27+
You can also check this [repo](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin/src/rules) for ESLint rule examples.

0 commit comments

Comments
 (0)