Skip to content

Commit

Permalink
v1.0.46
Browse files Browse the repository at this point in the history
Do not enforce unsafe optional chaining
  • Loading branch information
eliottvincent committed Aug 12, 2023
1 parent 95edd6c commit ac20bff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-crisp",
"version": "1.0.45",
"version": "1.0.46",
"description": "Custom EsLint Rules for Crisp",
"main": "index.js",
"author": "Crisp IM SAS",
Expand Down
4 changes: 3 additions & 1 deletion rules/enforce-optional.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module.exports = {
create(context) {
const sourceCode = context.getSourceCode();
// Search for `foo && foo.` or `foo && foo[`
const pattern = /\b(\w\S+)\s&&\s+\1\b[\[\.]/g;
// Notice: do not match `foo && foo.bar !==` or `foo && foo[bar] !==`, \
// as the optional version would be unsafe
const pattern = /\b(\w\S+)\s&&\s+\1\b[\[\.](?!\w\S+\s\!\=\=)/g;

return {
Program() {
Expand Down

0 comments on commit ac20bff

Please sign in to comment.