ignore-lint-errors 1.1.3 → 1.1.5

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.
@@ -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.3",
3
+ "version": "1.1.5",
4
4
  "description": "Codemod to ignore lint errors per line",
5
5
  "keywords": [
6
6
  "codemod",
@@ -23,27 +23,27 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@codemod-utils/ast-javascript": "^4.2.1",
26
+ "@codemod-utils/ast-javascript": "^4.3.0",
27
27
  "@codemod-utils/ast-template": "^4.1.0",
28
28
  "@codemod-utils/ast-template-tag": "^2.7.0",
29
29
  "@codemod-utils/files": "^4.1.0",
30
30
  "@codemod-utils/package-json": "^4.1.0",
31
- "yargs": "^18.0.0"
31
+ "yargs": "^18.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@changesets/cli": "^2.31.0",
34
+ "@changesets/cli": "^2.31.1",
35
35
  "@codemod-utils/tests": "^3.1.0",
36
- "@ijlee2-frontend-configs/changesets": "^2.1.1",
37
- "@ijlee2-frontend-configs/eslint-config-node": "^4.1.0",
38
- "@ijlee2-frontend-configs/prettier": "^3.3.0",
36
+ "@ijlee2-frontend-configs/changesets": "^2.1.2",
37
+ "@ijlee2-frontend-configs/eslint-config-node": "^4.2.0",
38
+ "@ijlee2-frontend-configs/prettier": "^3.3.2",
39
39
  "@sondr3/minitest": "^0.1.2",
40
40
  "@tsconfig/node22": "^22.0.5",
41
41
  "@tsconfig/strictest": "^2.0.8",
42
- "@types/node": "^22.20.0",
42
+ "@types/node": "^22.20.1",
43
43
  "@types/yargs": "^17.0.35",
44
- "concurrently": "^10.0.3",
45
- "eslint": "^10.6.0",
46
- "prettier": "^3.9.4",
44
+ "concurrently": "^10.0.4",
45
+ "eslint": "^10.8.1",
46
+ "prettier": "^3.9.6",
47
47
  "typescript": "^6.0.3"
48
48
  },
49
49
  "engines": {
@@ -59,7 +59,7 @@
59
59
  "lint:js:fix": "eslint . --fix",
60
60
  "lint:types": "tsc --noEmit",
61
61
  "release:prepare": "changeset version",
62
- "release:publish": "pnpm build && pnpm publish",
62
+ "release:publish": "pnpm build && changeset publish",
63
63
  "test": "sh build.sh --test && mt dist-for-testing --quiet"
64
64
  },
65
65
  "bin": {