Skip to content

Commit 9dea8e6

Browse files
Apply suggestions from code review
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
1 parent b24601a commit 9dea8e6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/rules/simplify-set-operations.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ description: "require simplify set operations"
1616
1717
## :book: Rule Details
1818

19-
This rule aims to optimize patterns by simplifying set operations on character classes (with `v` flag).
19+
This rule aims to optimize patterns by simplifying set operations in character classes (with `v` flag).
2020

2121
This rule does not report simple nested negations. (e.g. `/[^[^abc]]/v`)\
22-
If you want to report simple nested negations, use [regexp/negation] rule together.
22+
If you want to report simple nested negations, use the [regexp/negation] rule.
2323

2424
<eslint-code-block fix>
2525

@@ -48,8 +48,8 @@ This rule attempts to simplify set operations in the ways listed below:
4848

4949
#### De Morgan's laws
5050

51-
This rule uses De Morgan's laws to look for patterns that can convert multiple negations into a single negation, reports on them, auto-fix them.\
52-
For example, `/[[^a]&&[^b]]/v` is equivalent to `/[^ab]/v`, `/[[^a][^b]]/v` is equivalent to `/[^a&&b]/v`.
51+
This rule uses De Morgan's laws to look for patterns that can convert multiple negations into a single negation, reports on them, and auto-fix them.\
52+
For example, `/[[^a]&&[^b]]/v` is equivalent to `/[^ab]/v`, and `/[[^a][^b]]/v` is equivalent to `/[^a&&b]/v`.
5353

5454
See <https://en.wikipedia.org/wiki/De_Morgan's_laws>.
5555

@@ -67,7 +67,7 @@ For example, `/[a--[^b]]/v` is equivalent to `/[a&&b]/v`.
6767

6868
### Auto Fixes
6969

70-
This rule's auto-fix does not remove unnecessary brackets. For example, `/[[^a]&&[^b]]/v` will be automatically fixed to `/[[a][b]]/v`.\
70+
This rule's auto-fix does not remove unnecessary brackets. For example, `/[[^a]&&[^b]]/v` will be automatically fixed to `/[^[a][b]]/v`.\
7171
If you want to remove unnecessary brackets (e.g. auto-fixed to `/[^ab]/v`), use [regexp/no-useless-character-class] rule together.
7272

7373
## :wrench: Options

lib/rules/simplify-set-operations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export default createRule("simplify-set-operations", {
264264
* - `[[^a][^b]]` -> `[^a&&b]`
265265
*/
266266
function toNegationOfConjunction(ccNode: CharacterClass) {
267-
if (ccNode.elements.length <= 1 || !flags.unicodeSets) {
267+
if (ccNode.elements.length <= 1) {
268268
return false
269269
}
270270
const elements: CharacterClassElement[] = ccNode.elements

0 commit comments

Comments
 (0)