danger / danger/danger-js

[BUG] Double-hyphens can be interpreted as diff-commands leading danger to try to load comments as modified file paths

Open
#1,387 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
5.5k
Forks
381
Avg merge
2h 8m
Merged PRs (30d)
6

Description

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Modify a file with a `no-restricted-import` rule disabled like this

```
/* eslint-disable-next-line no-restricted-imports
-- we need to use useStore to access to Redux Store
*/
import { useStore } from "react-redux";
```

2. Log the modified files `danger.git.modified_files`
3. The comment `we need to use useStore to access to Redux Store` is listed
4.

**Expected behavior**
`we need to use useStore to access to Redux Store` shouldn't be in the list of modified files

**Screenshots**
![Screenshot 2023-07-24 at 1 57 32 PM](https://github.com/danger/danger-js/assets/82107248/006b2cc5-f443-41b3-862c-9af0685fef9b)

**Your Environment**

| software | version
| ---------------- | -------
| danger.js | 11.2.1
| node | 18.15.0
| npm | 9.5.0
| Operating System | MacOs

**Additional context**

I'm using https://github.com/mysticatea/eslint-plugin-eslint-comments to force comments when disable a lint rule.

The error only happen when the file is modified, If I create a new file it works as expected

danger.git.created_files doesn't take the comment as a new file
danger.git.modified_files take the comment as a new file

Contributor guide

Open the contributing guide

Research direction

Start by tracing how danger.git.modified_files parses modified-file output, comparing it with danger.git.created_files. Reproduce the provided ESLint-disable comment case and verify that the comment is excluded from modified files while legitimate paths remain; confirm the created-file behavior still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.