Skip to content

Allow modifying Set and Map in immutable rule lint config #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vmasek
Copy link
Contributor

@vmasek vmasek commented May 12, 2025

It seems that recently mutation to new Set() or new Map() has started to be reported.
eslint-functional/eslint-plugin-functional#935

Resulting in many new lint errors in projects that considered following code as quite clean

export function extractAllDirectories(files: string[]): string[] {
  const allDirs = new Set<string>();
  files.forEach(file => {
    const dirs = pathPrefixes(file).filter(f => f !== file);
    dirs.forEach(dir => {
      allDirs.add(dir);
    });
  });
  return [...allDirs.values()].sort();
}
  const prevItemMap = new Map<T, T>();
  const currItemMap = new Map<T, T>();

  for (const curr of after) {
    for (const prev of before) {
      if (equals(prev, curr)) {
        prevItemMap.set(curr, prev);
        currItemMap.set(prev, curr);
        break;
      }
    }
  }

@vmasek vmasek requested a review from matejchalk May 12, 2025 14:38
@@ -83,6 +83,7 @@ export const NAMING_CONVENTION_OPTIONS_ANGULAR = [
];

export const IMMUTABLE_DATA_OPTIONS = {
ignoreMapsAndSets: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option was added in eslint-plugin-functional's v9.0.0. But we also support older versions. I'd be concerned they'd throw because of an unknown option. In which case, we should handle this more defensively.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add condition to take care of this

@vmasek
Copy link
Contributor Author

vmasek commented May 12, 2025

@matejchalk do you know what is the problem with docs? Locally it do les not generate difference

@matejchalk
Copy link
Contributor

matejchalk commented May 13, 2025

do you know what is the problem with docs? Locally it do les not generate difference

In react.md, the no-children-prop rule is moved to a different position in your branch. When I run npm run docs locally, it puts it back to original position. So reverting this change should fix the CI check.

@vmasek
Copy link
Contributor Author

vmasek commented May 13, 2025

do you know what is the problem with docs? Locally it do les not generate difference

In react.md, the no-children-prop rule is moved to a different position in your branch. When I run npm run docs locally, it puts it back to original position. So reverting this change should fix the CI check.

I see, classic localeCompare & sort issue 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants