ignore-lint-errors 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2026
3
+ Copyright (c) 2026 Isaac J. Lee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -41,12 +41,19 @@ export function getIgnoredRules(lineOfCode, options) {
41
41
  visitComment(path) {
42
42
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
43
43
  const comment = path.value.value.trim();
44
- if (comment.startsWith(options.ignoreDirective)) {
45
- ignoredRules = comment
46
- .replace(new RegExp(`^${options.ignoreDirective}\\s+`, 'g'), '')
47
- .split(',')
48
- .map((token) => token.trim());
44
+ if (!comment.startsWith(options.ignoreDirective)) {
45
+ return false;
49
46
  }
47
+ ignoredRules = comment
48
+ .replace(new RegExp(`^${options.ignoreDirective}\\s*`, 'g'), '')
49
+ .split(',')
50
+ .reduce((accumulator, token) => {
51
+ const rule = token.trim();
52
+ if (rule) {
53
+ accumulator.push(rule);
54
+ }
55
+ return accumulator;
56
+ }, []);
50
57
  return false;
51
58
  },
52
59
  });
@@ -1,15 +1,14 @@
1
- import { relative, sep } from 'node:path';
2
- import { getFilesWithErrors } from './shared/index.js';
1
+ import { getFilesWithErrors, getMessage, getRelativePath, } from './shared/index.js';
3
2
  export const outputFilePath = '.ignore-lint-errors/eslint.txt';
4
3
  function normalize(file, projectRoot) {
5
4
  const filePathToData = new Map();
6
- const records = JSON.parse(file);
7
- records.forEach((record) => {
8
- const { filePath: absoluteFilePath, messages } = record;
9
- const filePath = relative(projectRoot, absoluteFilePath).replaceAll(sep, '/');
5
+ const results = JSON.parse(file);
6
+ results.forEach((result) => {
7
+ const { filePath: absoluteFilePath, messages: rawErrors } = result;
8
+ const filePath = getRelativePath(absoluteFilePath, projectRoot);
10
9
  const lineToRules = new Map();
11
10
  const data = new Map();
12
- messages.forEach(({ line, ruleId }) => {
11
+ rawErrors.forEach(({ line, ruleId }) => {
13
12
  if (lineToRules.has(line)) {
14
13
  lineToRules.get(line).push(ruleId);
15
14
  }
@@ -18,8 +17,7 @@ function normalize(file, projectRoot) {
18
17
  }
19
18
  });
20
19
  lineToRules.forEach((rules, line) => {
21
- const message = Array.from(new Set(rules.sort())).join(', ');
22
- data.set(line, message);
20
+ data.set(line, getMessage(rules));
23
21
  });
24
22
  filePathToData.set(filePath, data);
25
23
  });
@@ -1,4 +1,4 @@
1
- import { getFilesWithErrors } from './shared/index.js';
1
+ import { getFilesWithErrors, getMessage } from './shared/index.js';
2
2
  export const outputFilePath = '.ignore-lint-errors/oxlint.txt';
3
3
  function extractRuleId(code) {
4
4
  const matches = code.match(/^.+\((.+)\)$/);
@@ -9,30 +9,30 @@ function extractRuleId(code) {
9
9
  }
10
10
  function normalize(file) {
11
11
  const filePathToData = new Map();
12
- const { diagnostics } = JSON.parse(file);
13
- const filePathToMessages = new Map();
14
- diagnostics.forEach((diagnostic) => {
15
- const { code, filename: filePath, labels } = diagnostic;
12
+ const { diagnostics: results } = JSON.parse(file);
13
+ const filePathToRawErrors = new Map();
14
+ results.forEach((result) => {
15
+ const { code, filename: filePath, labels } = result;
16
16
  if (code === undefined) {
17
17
  return;
18
18
  }
19
19
  const line = labels[0].span.line;
20
20
  const ruleId = extractRuleId(code);
21
- const message = {
21
+ const rawError = {
22
22
  line,
23
23
  ruleId,
24
24
  };
25
- if (filePathToMessages.has(filePath)) {
26
- filePathToMessages.get(filePath).push(message);
25
+ if (filePathToRawErrors.has(filePath)) {
26
+ filePathToRawErrors.get(filePath).push(rawError);
27
27
  }
28
28
  else {
29
- filePathToMessages.set(filePath, [message]);
29
+ filePathToRawErrors.set(filePath, [rawError]);
30
30
  }
31
31
  });
32
- filePathToMessages.forEach((messages, filePath) => {
33
- const data = new Map();
32
+ filePathToRawErrors.forEach((rawErrors, filePath) => {
34
33
  const lineToRules = new Map();
35
- messages.forEach(({ line, ruleId }) => {
34
+ const data = new Map();
35
+ rawErrors.forEach(({ line, ruleId }) => {
36
36
  if (lineToRules.has(line)) {
37
37
  lineToRules.get(line).push(ruleId);
38
38
  }
@@ -41,8 +41,7 @@ function normalize(file) {
41
41
  }
42
42
  });
43
43
  lineToRules.forEach((rules, line) => {
44
- const message = Array.from(new Set(rules.sort())).join(', ');
45
- data.set(line, message);
44
+ data.set(line, getMessage(rules));
46
45
  });
47
46
  filePathToData.set(filePath, data);
48
47
  });
@@ -1,3 +1,4 @@
1
+ import { relative, sep } from 'node:path';
1
2
  export function getFilesWithErrors(filePathToData) {
2
3
  const filesWithErrors = [];
3
4
  filePathToData.forEach((data, filePath) => {
@@ -27,3 +28,9 @@ export function getFilesWithErrors(filePathToData) {
27
28
  });
28
29
  return filesWithErrors;
29
30
  }
31
+ export function getMessage(rules) {
32
+ return Array.from(new Set(rules.sort())).join(', ');
33
+ }
34
+ export function getRelativePath(absoluteFilePath, projectRoot) {
35
+ return relative(projectRoot, absoluteFilePath).replaceAll(sep, '/');
36
+ }
@@ -1,18 +1,17 @@
1
- import { relative, sep } from 'node:path';
2
- import { getFilesWithErrors } from './shared/index.js';
1
+ import { getFilesWithErrors, getMessage, getRelativePath, } from './shared/index.js';
3
2
  export const outputFilePath = '.ignore-lint-errors/stylelint.txt';
4
3
  function normalize(file, projectRoot) {
5
4
  const filePathToData = new Map();
6
- const records = JSON.parse(file);
7
- records.forEach((record) => {
8
- const { errored, source: absoluteFilePath, warnings } = record;
5
+ const results = JSON.parse(file);
6
+ results.forEach((result) => {
7
+ const { errored, source: absoluteFilePath, warnings: rawErrors } = result;
8
+ const filePath = getRelativePath(absoluteFilePath, projectRoot);
9
9
  if (!errored) {
10
10
  return;
11
11
  }
12
- const filePath = relative(projectRoot, absoluteFilePath).replaceAll(sep, '/');
13
12
  const lineToRules = new Map();
14
13
  const data = new Map();
15
- warnings.forEach(({ line, rule }) => {
14
+ rawErrors.forEach(({ line, rule }) => {
16
15
  if (lineToRules.has(line)) {
17
16
  lineToRules.get(line).push(rule);
18
17
  }
@@ -21,8 +20,7 @@ function normalize(file, projectRoot) {
21
20
  }
22
21
  });
23
22
  lineToRules.forEach((rules, line) => {
24
- const message = Array.from(new Set(rules.sort())).join(', ');
25
- data.set(line, message);
23
+ data.set(line, getMessage(rules));
26
24
  });
27
25
  filePathToData.set(filePath, data);
28
26
  });
@@ -3,8 +3,9 @@ import { getFilesWithErrors } from './shared/index.js';
3
3
  export const outputFilePath = '.ignore-lint-errors/typescript.txt';
4
4
  function normalize(file) {
5
5
  const filePathToData = new Map();
6
- file.split(EOL).forEach((str) => {
7
- const matches = str.match(/^(.+)\((\d+),\d+\): error TS\d+: (.+)\.$/);
6
+ const results = file.split(EOL);
7
+ results.forEach((result) => {
8
+ const matches = result.match(/^(.+)\((\d+),\d+\): error TS\d+: (.+)\.$/);
8
9
  if (matches === null) {
9
10
  return;
10
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ignore-lint-errors",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Codemod to ignore lint errors per line",
5
5
  "keywords": [
6
6
  "codemod",
@@ -19,7 +19,6 @@
19
19
  "author": "Isaac J. Lee",
20
20
  "type": "module",
21
21
  "main": "dist/src/index.js",
22
- "bin": "dist/bin/ignore-lint-errors.js",
23
22
  "files": [
24
23
  "dist"
25
24
  ],
@@ -35,16 +34,16 @@
35
34
  "@changesets/cli": "^2.31.0",
36
35
  "@codemod-utils/tests": "^3.1.0",
37
36
  "@ijlee2-frontend-configs/changesets": "^2.1.1",
38
- "@ijlee2-frontend-configs/eslint-config-node": "^4.1.0",
39
- "@ijlee2-frontend-configs/prettier": "^3.3.0",
37
+ "@ijlee2-frontend-configs/eslint-config-node": "^4.1.1",
38
+ "@ijlee2-frontend-configs/prettier": "^3.3.1",
40
39
  "@sondr3/minitest": "^0.1.2",
41
40
  "@tsconfig/node22": "^22.0.5",
42
41
  "@tsconfig/strictest": "^2.0.8",
43
- "@types/node": "^22.20.0",
42
+ "@types/node": "^22.20.1",
44
43
  "@types/yargs": "^17.0.35",
45
44
  "concurrently": "^10.0.3",
46
- "eslint": "^10.6.0",
47
- "prettier": "^3.9.4",
45
+ "eslint": "^10.7.0",
46
+ "prettier": "^3.9.5",
48
47
  "typescript": "^6.0.3"
49
48
  },
50
49
  "engines": {
@@ -62,5 +61,8 @@
62
61
  "release:prepare": "changeset version",
63
62
  "release:publish": "pnpm build && changeset publish",
64
63
  "test": "sh build.sh --test && mt dist-for-testing --quiet"
64
+ },
65
+ "bin": {
66
+ "ignore-lint-errors": "dist/bin/ignore-lint-errors.js"
65
67
  }
66
68
  }