xo 1.0.2 → 1.0.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/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
@@ -161,11 +161,14 @@ export class Xo {
161
161
  };
162
162
  // Apply TS rules to all files
163
163
  tsConfig.files = [tsFilesGlob];
164
- // Set the other rules to the original config
165
- config.rules = Object.fromEntries(otherRules);
164
+ const otherConfig = {
165
+ ...config,
166
+ // Set the other rules to the original config
167
+ rules: Object.fromEntries(otherRules),
168
+ };
166
169
  // These rules should still apply to all files
167
- config.files = [allFilesGlob];
168
- return [tsConfig, config];
170
+ otherConfig.files = [allFilesGlob];
171
+ return [tsConfig, otherConfig];
169
172
  });
170
173
  this.prettier = this.xoConfig.some(config => config.prettier);
171
174
  this.prettierConfig = await prettier.resolveConfig(flatConfigPath, { editorconfig: true }) ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xo",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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 && husky",
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"