ignore-lint-errors 0.7.0 → 0.8.0

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/README.md CHANGED
@@ -65,6 +65,33 @@ pnpx ignore-lint-errors --root <path/to/your/project>
65
65
 
66
66
  </details>
67
67
 
68
+ <details>
69
+
70
+ <summary>Optional: Specify files to lint</summary>
71
+
72
+ Pass `--src` to lint specific files.
73
+
74
+ ```sh
75
+ # eslint supports files
76
+ pnpx ignore-lint-errors --linter eslint --src app/components/example-1.gts app/templates/example-2.gts
77
+
78
+ # eslint supports directories
79
+ pnpx ignore-lint-errors --linter eslint --src app tests
80
+
81
+ # eslint supports globs
82
+ pnpx ignore-lint-errors --linter eslint --src app/{components,templates}/**/*.gts
83
+ ```
84
+
85
+ ```sh
86
+ # stylelint supports files
87
+ pnpx ignore-lint-errors --linter stylelint --src app/components/example-1.module.css app/templates/example-2.module.css
88
+
89
+ # stylelint supports globs
90
+ pnpx ignore-lint-errors --linter stylelint --src **/*.scss
91
+ ```
92
+
93
+ </details>
94
+
68
95
 
69
96
  ### Limitations
70
97
 
@@ -15,11 +15,17 @@ const argv = yargs(hideBin(process.argv))
15
15
  .option('root', {
16
16
  describe: 'Where to run the codemod',
17
17
  type: 'string',
18
+ })
19
+ .option('src', {
20
+ describe: 'Locations of files to lint',
21
+ string: true,
22
+ type: 'array',
18
23
  })
19
24
  .demandOption(['linter'])
20
25
  .parseSync();
21
26
  const codemodOptions = {
22
27
  linter: argv['linter'],
23
28
  projectRoot: argv['root'] ?? process.cwd(),
29
+ src: argv['src'],
24
30
  };
25
31
  runCodemod(codemodOptions);
@@ -13,10 +13,11 @@ function findDependencies(projectRoot) {
13
13
  };
14
14
  }
15
15
  export function createOptions(codemodOptions) {
16
- const { linter, projectRoot } = codemodOptions;
16
+ const { linter, projectRoot, src } = codemodOptions;
17
17
  return {
18
18
  dependencies: findDependencies(projectRoot),
19
19
  linter,
20
20
  projectRoot,
21
+ src,
21
22
  };
22
23
  }
@@ -1,9 +1,44 @@
1
1
  import { execSync } from 'node:child_process';
2
+ import { findFiles } from '@codemod-utils/files';
2
3
  import { outputFilePath } from '../../utils/linters/eslint.js';
4
+ function getConcurrencyOption(options) {
5
+ const { projectRoot } = options;
6
+ let isConcurrencySupported = true;
7
+ try {
8
+ const command = [
9
+ './node_modules/.bin/eslint does-not-exist.js',
10
+ '--concurrency off',
11
+ '--no-error-on-unmatched-pattern',
12
+ '2>/dev/null', // Suppress output to process.stderr
13
+ ].join(' ');
14
+ execSync(command, { cwd: projectRoot });
15
+ }
16
+ catch {
17
+ isConcurrencySupported = false;
18
+ }
19
+ if (!isConcurrencySupported) {
20
+ return '';
21
+ }
22
+ const filePaths = findFiles('**/*.{gjs,gts,js,ts}', {
23
+ ignoreList: ['{dist,node_modules}/**/*', '**/*.d.ts'],
24
+ projectRoot,
25
+ });
26
+ const concurrency = Math.max(Math.ceil(Math.log10(filePaths.length)), 1);
27
+ return `--concurrency ${concurrency}`;
28
+ }
29
+ function getSrc(options) {
30
+ const { src } = options;
31
+ if (src === undefined) {
32
+ return '.';
33
+ }
34
+ return src.map((token) => `"${token}"`).join(' ');
35
+ }
3
36
  export function runEslint(options) {
4
37
  const { projectRoot } = options;
5
38
  const command = [
6
39
  './node_modules/.bin/eslint',
40
+ getSrc(options),
41
+ getConcurrencyOption(options),
7
42
  '--format json',
8
43
  `--output-file ${outputFilePath}`,
9
44
  '--quiet',
@@ -1,10 +1,17 @@
1
1
  import { execSync } from 'node:child_process';
2
2
  import { outputFilePath } from '../../utils/linters/stylelint.js';
3
+ function getSrc(options) {
4
+ const { src } = options;
5
+ if (src === undefined) {
6
+ return '**/*.css';
7
+ }
8
+ return src.map((token) => `"${token}"`).join(' ');
9
+ }
3
10
  export function runStylelint(options) {
4
11
  const { projectRoot } = options;
5
12
  const command = [
6
- './node_modules/.bin/stylelint "**/*.css"',
7
- '--allow-empty-input',
13
+ './node_modules/.bin/stylelint',
14
+ getSrc(options),
8
15
  '--formatter json',
9
16
  `--output-file ${outputFilePath}`,
10
17
  '--quiet',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ignore-lint-errors",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Codemod to ignore lint errors per line",
5
5
  "keywords": [
6
6
  "codemod",