xo 1.0.2 → 1.0.3

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/dist/cli.js CHANGED
@@ -6,7 +6,8 @@ import formatterPretty from 'eslint-formatter-pretty';
6
6
  import getStdin from 'get-stdin';
7
7
  import meow from 'meow';
8
8
  import { pathExists } from 'path-exists';
9
- import { tsExtensions } from './lib/constants.js';
9
+ import findCacheDirectory from 'find-cache-directory';
10
+ import { cacheDirName, tsExtensions } from './lib/constants.js';
10
11
  import { Xo } from './lib/xo.js';
11
12
  import openReport from './lib/open-report.js';
12
13
  const cli = meow(`
@@ -17,12 +18,14 @@ const cli = meow(`
17
18
  --fix Automagically fix issues
18
19
  --reporter Reporter to use
19
20
  --space Use space indent instead of tabs [Default: 2]
21
+ --config Path to a XO configuration file
20
22
  --semicolon Use semicolons [Default: true]
21
- --prettier Conform to Prettier code style [Default: false]
22
23
  --react Include React specific parsing and xo-react linting rules [Default: false]
23
24
  --prettier Format with prettier or turn off prettier conflicted rules when set to 'compat' [Default: false]
24
25
  --print-config Print the effective ESLint config for the given file
26
+ --version Print XO version
25
27
  --open Open files with issues in your editor
28
+ --quiet Show only errors and no warnings
26
29
  --stdin Validate/fix code from stdin
27
30
  --stdin-filename Specify a filename for the --stdin option
28
31
  --ignore Ignore pattern globs, can be set multiple times
@@ -151,7 +154,8 @@ if (cliOptions.stdin) {
151
154
  if (cliOptions.stdinFilename && tsExtensions.includes(path.extname(cliOptions.stdinFilename).slice(1))) {
152
155
  const absoluteFilePath = path.resolve(cliOptions.cwd, cliOptions.stdinFilename);
153
156
  if (!await pathExists(absoluteFilePath)) {
154
- cliOptions.stdinFilename = path.join(cliOptions.cwd, 'node_modules', '.cache', 'xo-linter', path.basename(absoluteFilePath));
157
+ const cacheDir = findCacheDirectory({ name: cacheDirName, cwd: linterOptions.cwd }) ?? path.join(cliOptions.cwd, 'node_modules', '.cache', cacheDirName);
158
+ cliOptions.stdinFilename = path.join(cacheDir, path.basename(absoluteFilePath));
155
159
  shouldRemoveStdInFile = true;
156
160
  baseXoConfigOptions.ignores = [
157
161
  '!**/node_modules/**',
@@ -181,7 +185,7 @@ if (cliOptions.stdin) {
181
185
  process.exit(1);
182
186
  }
183
187
  const xo = new Xo(linterOptions, baseXoConfigOptions);
184
- await log(await xo.lintText(stdin, { filePath: cliOptions.stdinFilename, warnIgnored: true }));
188
+ await log(await xo.lintText(stdin, { filePath: cliOptions.stdinFilename, warnIgnored: false }));
185
189
  if (shouldRemoveStdInFile) {
186
190
  await fs.rm(cliOptions.stdinFilename);
187
191
  }
@@ -31,7 +31,7 @@ export async function handleTsconfig({ cwd, files }) {
31
31
  // If we match on excluded, then we definitively know that there is no tsconfig match.
32
32
  if (Array.isArray(tsConfig.exclude)) {
33
33
  const exclude = Array.isArray(tsConfig.exclude) ? tsConfig.exclude : [];
34
- hasMatch = !micromatch.isMatch(filePath, exclude, micromatchOptions);
34
+ hasMatch = !micromatch.contains(filePath, exclude, micromatchOptions);
35
35
  }
36
36
  else {
37
37
  // Not explicitly excluded and included by tsconfig defaults
@@ -45,7 +45,7 @@ export async function handleTsconfig({ cwd, files }) {
45
45
  const exclude = Array.isArray(tsConfig.exclude) ? tsConfig.exclude : [];
46
46
  // If we also have an exlcude we need to check all the arrays, (files, include, exclude)
47
47
  // this check not excluded and included in one of the file/include array
48
- hasMatch = !micromatch.isMatch(filePath, exclude, micromatchOptions) && micromatch.isMatch(filePath, [...include, ...files], micromatchOptions);
48
+ hasMatch = !micromatch.contains(filePath, exclude, micromatchOptions) && micromatch.isMatch(filePath, [...include, ...files], micromatchOptions);
49
49
  }
50
50
  if (!hasMatch) {
51
51
  unincludedFiles.push(filePath);
package/dist/lib/xo.js CHANGED
@@ -125,7 +125,8 @@ export class Xo {
125
125
  });
126
126
  this.xoConfig = [
127
127
  this.baseXoConfig,
128
- ...flatOptions,
128
+ // Ensure resolved options do not mutate between runs
129
+ ...structuredClone(flatOptions),
129
130
  ];
130
131
  // Split off the TS rules in a special case, so that you won't get errors
131
132
  // for JS files when the TS rules are not in the config.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xo",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "JavaScript/TypeScript linter (ESLint wrapper) with great defaults",
5
5
  "license": "MIT",
6
6
  "repository": "xojs/xo",
@@ -25,7 +25,7 @@
25
25
  "build:watch": "tsc --watch",
26
26
  "clean": "rm -rf dist",
27
27
  "lint": "node dist/cli.js",
28
- "prepare": "husky",
28
+ "prepare": "npm run build",
29
29
  "release": "np",
30
30
  "test": "npm run build && npm run lint && npm run test:setup && ava",
31
31
  "test:setup": "node scripts/setup-tests"