xo 0.56.0 → 0.58.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.
@@ -41,7 +41,7 @@ module.exports = {
41
41
  checkFilenames: false,
42
42
  checkDefaultAndNamespaceImports: false,
43
43
  checkShorthandImports: false,
44
- extendDefaultReplacements: false,
44
+ extendDefaultReplacements: true,
45
45
  replacements: {
46
46
  // https://thenextweb.com/dd/2020/07/13/linux-kernel-will-no-longer-use-terms-blacklist-and-slave/
47
47
  whitelist: {
@@ -57,7 +57,7 @@ module.exports = {
57
57
  secondary: true,
58
58
  },
59
59
 
60
- // Not part of `eslint-plugin-unicorn`
60
+ // Reverse.
61
61
  application: {
62
62
  app: true,
63
63
  },
@@ -65,68 +65,75 @@ module.exports = {
65
65
  apps: true,
66
66
  },
67
67
 
68
- // Part of `eslint-plugin-unicorn`
69
- arr: {
70
- array: true,
68
+ // Disable some that may be too annoying.
69
+ env: false,
70
+ i: false, // Do it at some point, but not ready for it yet. Maybe 2025.
71
+
72
+ // Not part of `eslint-plugin-unicorn`. Upstream them at some point.
73
+ bin: {
74
+ binary: true,
71
75
  },
72
- e: {
73
- error: true,
74
- event: true,
76
+ eof: {
77
+ endOfFile: true,
75
78
  },
76
- el: {
77
- element: true,
79
+ impl: {
80
+ implement: true,
81
+ implementation: true,
78
82
  },
79
- elem: {
80
- element: true,
83
+ anim: {
84
+ animation: true,
81
85
  },
82
- len: {
83
- length: true,
86
+ calc: {
87
+ calculate: true,
84
88
  },
85
- msg: {
86
- message: true,
89
+ dict: {
90
+ dictionary: true,
87
91
  },
88
- num: {
89
- number: true,
92
+ dup: {
93
+ duplicate: true,
90
94
  },
91
- obj: {
92
- object: true,
95
+ enc: {
96
+ encode: true,
97
+ encryption: true,
93
98
  },
94
- opts: {
95
- options: true,
99
+ gen: {
100
+ generate: true,
101
+ general: true,
96
102
  },
97
- param: {
98
- parameter: true,
103
+ gfx: {
104
+ graphics: true,
99
105
  },
100
- params: {
101
- parameters: true,
106
+ inc: {
107
+ increment: true,
102
108
  },
103
- prev: {
104
- previous: true,
109
+ iter: {
110
+ iterate: true,
111
+ iterator: true,
105
112
  },
106
- req: {
107
- request: true,
113
+ nav: {
114
+ navigate: true,
115
+ navigation: true,
108
116
  },
109
- res: {
110
- response: true,
111
- result: true,
117
+ norm: {
118
+ normalize: true,
112
119
  },
113
- ret: {
114
- returnValue: true,
120
+ notif: {
121
+ notification: true,
115
122
  },
116
- str: {
117
- string: true,
123
+ perf: {
124
+ performance: true,
118
125
  },
119
- temp: {
120
- temporary: true,
126
+ proc: {
127
+ process: true,
121
128
  },
122
- tmp: {
123
- temporary: true,
129
+ rand: {
130
+ random: true,
124
131
  },
125
- val: {
126
- value: true,
132
+ sys: {
133
+ system: true,
127
134
  },
128
- err: {
129
- error: true,
135
+ temp: {
136
+ temporary: true,
130
137
  },
131
138
  },
132
139
  },
@@ -153,13 +160,10 @@ module.exports = {
153
160
  },
154
161
  ],
155
162
 
156
- // Temporarily disabled because it's buggy with TypeScript: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2175
163
+ // Temporarily disabled because of https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2218
157
164
  'unicorn/no-empty-file': 'off',
158
165
 
159
- // TODO: Disabled for now until it becomes more stable: https://github.com/sindresorhus/eslint-plugin-unicorn/search?q=consistent-destructuring+is:issue&state=open&type=issues
160
- 'unicorn/consistent-destructuring': 'off',
161
-
162
- // TODO: Disabled for now as I don't have time to deal with the backslash that might come from this. Try to enable this rule in 2021.
166
+ // TODO: Disabled for now as I don't have time to deal with the backslash that might come from this. Try to enable this rule in 2025.
163
167
  'unicorn/no-null': 'off',
164
168
 
165
169
  // We only enforce it for single-line statements to not be too opinionated.
@@ -355,10 +359,13 @@ module.exports = {
355
359
  // 'n/shebang': 'error',
356
360
 
357
361
  'n/no-deprecated-api': 'error',
358
- 'n/prefer-global/buffer': [
359
- 'error',
360
- 'never',
361
- ],
362
+
363
+ // We no longer enforce this as we don't want to use Buffer at all, but sometimes we need to conditionally use the `Buffer` global, but we then don't want the import so the module works cross-platform.
364
+ // 'n/prefer-global/buffer': [
365
+ // 'error',
366
+ // 'never',
367
+ // ],
368
+
362
369
  'n/prefer-global/console': [
363
370
  'error',
364
371
  'always',
package/index.js CHANGED
@@ -28,7 +28,9 @@ const globFiles = async (patterns, options) => {
28
28
 
29
29
  const files = await globby(
30
30
  patterns,
31
- {ignore: ignores, gitignore: true, absolute: true, cwd},
31
+ {
32
+ ignore: ignores, gitignore: true, absolute: true, cwd,
33
+ },
32
34
  );
33
35
 
34
36
  return files.filter(file => extensions.includes(path.extname(file).slice(1)));
package/lib/constants.js CHANGED
@@ -7,6 +7,7 @@ const DEFAULT_IGNORES = [
7
7
  '**/*.min.js',
8
8
  'vendor/**',
9
9
  'dist/**',
10
+ 'distribution/**',
10
11
  'tap-snapshots/*.{cjs,js}',
11
12
  ];
12
13
 
@@ -4,7 +4,7 @@ import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import arrify from 'arrify';
6
6
  import {mergeWith, flow, pick} from 'lodash-es';
7
- import {findUpSync} from 'find-up';
7
+ import {findUpSync} from 'find-up-simple';
8
8
  import findCacheDir from 'find-cache-dir';
9
9
  import prettier from 'prettier';
10
10
  import semver from 'semver';
@@ -83,7 +83,7 @@ const getEmptyXOConfig = () => ({
83
83
  extends: [],
84
84
  });
85
85
 
86
- const mergeFn = (previousValue, value, key) => {
86
+ const mergeFunction = (previousValue, value, key) => {
87
87
  if (Array.isArray(previousValue)) {
88
88
  if (MERGE_OPTIONS_CONCAT.includes(key)) {
89
89
  return [...previousValue, ...value];
@@ -102,14 +102,12 @@ The config files are searched starting from `options.filePath` if defined or `op
102
102
  const mergeWithFileConfig = async options => {
103
103
  options.cwd = path.resolve(options.cwd || process.cwd());
104
104
  const configExplorer = cosmiconfig(MODULE_NAME, {searchPlaces: CONFIG_FILES, loaders: {noExt: defaultLoaders['.json']}, stopDir: options.cwd});
105
- const pkgConfigExplorer = cosmiconfig('engines', {searchPlaces: ['package.json'], stopDir: options.cwd});
106
- if (options.filePath) {
107
- options.filePath = path.resolve(options.cwd, options.filePath);
108
- }
105
+ const packageConfigExplorer = cosmiconfig('engines', {searchPlaces: ['package.json'], stopDir: options.cwd});
106
+ options.filePath &&= path.resolve(options.cwd, options.filePath);
109
107
 
110
108
  const searchPath = options.filePath || options.cwd;
111
109
  const {config: xoOptions, filepath: xoConfigPath} = (await configExplorer.search(searchPath)) || {};
112
- const {config: enginesOptions} = (await pkgConfigExplorer.search(searchPath)) || {};
110
+ const {config: enginesOptions} = (await packageConfigExplorer.search(searchPath)) || {};
113
111
 
114
112
  options = normalizeOptions({
115
113
  ...xoOptions,
@@ -274,7 +272,7 @@ const buildConfig = (options, prettierOptions) => {
274
272
  buildTSConfig(options),
275
273
  buildExtendsConfig(options),
276
274
  buildPrettierConfig(options, prettierOptions),
277
- )(mergeWith(getEmptyConfig(), DEFAULT_CONFIG, mergeFn));
275
+ )(mergeWith(getEmptyConfig(), DEFAULT_CONFIG, mergeFunction));
278
276
  };
279
277
 
280
278
  const toValueMap = (array, value = true) => Object.fromEntries(array.map(item => [item, value]));
@@ -473,7 +471,7 @@ const mergeWithPrettierConfig = (options, prettierOptions) => {
473
471
  semi: options.semicolon !== false,
474
472
  },
475
473
  prettierOptions,
476
- mergeFn,
474
+ mergeFunction,
477
475
  );
478
476
  };
479
477
 
@@ -503,7 +501,7 @@ const applyOverrides = (file, options) => {
503
501
 
504
502
  const {applicable, hash} = findApplicableOverrides(path.relative(options.cwd, file), overrides);
505
503
 
506
- options = mergeWith(getEmptyXOConfig(), options, ...applicable.map(override => normalizeOptions(override)), mergeFn);
504
+ options = mergeWith(getEmptyXOConfig(), options, ...applicable.map(override => normalizeOptions(override)), mergeFunction);
507
505
  delete options.files;
508
506
  return {options, hash};
509
507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xo",
3
- "version": "0.56.0",
3
+ "version": "0.58.0",
4
4
  "description": "JavaScript/TypeScript linter (ESLint wrapper) with great defaults",
5
5
  "license": "MIT",
6
6
  "repository": "xojs/xo",
@@ -12,8 +12,9 @@
12
12
  },
13
13
  "type": "module",
14
14
  "bin": "./cli.js",
15
+ "sideEffects": false,
15
16
  "engines": {
16
- "node": ">=16"
17
+ "node": ">=18"
17
18
  },
18
19
  "scripts": {
19
20
  "test:clean": "find ./test -type d -name 'node_modules' -prune -not -path ./test/fixtures/project/node_modules -exec rm -rf '{}' +",
@@ -53,53 +54,53 @@
53
54
  "typescript"
54
55
  ],
55
56
  "dependencies": {
56
- "@eslint/eslintrc": "^2.1.0",
57
- "@typescript-eslint/eslint-plugin": "^6.0.0",
58
- "@typescript-eslint/parser": "^6.0.0",
57
+ "@eslint/eslintrc": "^3.0.2",
58
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
59
+ "@typescript-eslint/parser": "^7.1.1",
59
60
  "arrify": "^3.0.0",
60
- "cosmiconfig": "^8.2.0",
61
+ "cosmiconfig": "^8.3.6",
61
62
  "define-lazy-prop": "^3.0.0",
62
- "eslint": "^8.45.0",
63
- "eslint-config-prettier": "^8.8.0",
64
- "eslint-config-xo": "^0.43.1",
65
- "eslint-config-xo-typescript": "^1.0.0",
66
- "eslint-formatter-pretty": "^5.0.0",
67
- "eslint-import-resolver-webpack": "^0.13.2",
63
+ "eslint": "^8.57.0",
64
+ "eslint-config-prettier": "^9.1.0",
65
+ "eslint-config-xo": "^0.44.0",
66
+ "eslint-config-xo-typescript": "^4.0.0",
67
+ "eslint-formatter-pretty": "^6.0.1",
68
+ "eslint-import-resolver-webpack": "^0.13.8",
68
69
  "eslint-plugin-ava": "^14.0.0",
69
70
  "eslint-plugin-eslint-comments": "^3.2.0",
70
- "eslint-plugin-import": "~2.27.5",
71
- "eslint-plugin-n": "^16.0.1",
71
+ "eslint-plugin-import": "^2.29.1",
72
+ "eslint-plugin-n": "^16.6.2",
72
73
  "eslint-plugin-no-use-extend-native": "^0.5.0",
73
- "eslint-plugin-prettier": "^5.0.0",
74
- "eslint-plugin-unicorn": "^48.0.0",
75
- "esm-utils": "^4.1.2",
76
- "find-cache-dir": "^4.0.0",
77
- "find-up": "^6.3.0",
74
+ "eslint-plugin-prettier": "^5.1.3",
75
+ "eslint-plugin-unicorn": "^51.0.1",
76
+ "esm-utils": "^4.2.1",
77
+ "find-cache-dir": "^5.0.0",
78
+ "find-up-simple": "^1.0.0",
78
79
  "get-stdin": "^9.0.0",
79
- "get-tsconfig": "^4.6.2",
80
- "globby": "^13.2.2",
80
+ "get-tsconfig": "^4.7.3",
81
+ "globby": "^14.0.1",
81
82
  "imurmurhash": "^0.1.4",
82
83
  "json-stable-stringify-without-jsonify": "^1.0.1",
83
84
  "lodash-es": "^4.17.21",
84
- "meow": "^12.0.1",
85
+ "meow": "^13.2.0",
85
86
  "micromatch": "^4.0.5",
86
- "open-editor": "^4.0.0",
87
- "prettier": "^3.0.0",
88
- "semver": "^7.5.4",
87
+ "open-editor": "^4.1.1",
88
+ "prettier": "^3.2.5",
89
+ "semver": "^7.6.0",
89
90
  "slash": "^5.1.0",
90
91
  "to-absolute-glob": "^3.0.0",
91
- "typescript": "^5.1.6"
92
+ "typescript": "^5.4.2"
92
93
  },
93
94
  "devDependencies": {
94
- "ava": "^5.3.1",
95
+ "ava": "^6.1.2",
95
96
  "eslint-config-xo-react": "^0.27.0",
96
- "eslint-plugin-react": "^7.31.10",
97
+ "eslint-plugin-react": "^7.34.0",
97
98
  "eslint-plugin-react-hooks": "^4.6.0",
98
- "execa": "^7.1.1",
99
+ "execa": "^8.0.1",
99
100
  "nyc": "^15.1.0",
100
101
  "proxyquire": "^2.1.3",
101
102
  "temp-write": "^5.0.0",
102
- "webpack": "^5.88.1"
103
+ "webpack": "^5.90.3"
103
104
  },
104
105
  "xo": {
105
106
  "ignores": [
package/readme.md CHANGED
@@ -282,7 +282,7 @@ Use one or more [shareable configs](https://eslint.org/docs/developer-guide/shar
282
282
 
283
283
  Type: `string[]`
284
284
 
285
- Allow more extensions to be linted besides `.js`, `.jsx`, `.mjs`, and `.cjs`. Make sure they're supported by ESLint or an ESLint plugin.
285
+ Allow more extensions to be linted besides `.js`, `.jsx`, `.mjs`, and `.cjs` as well as their TypeScript equivalents `.ts`, `.tsx`, `.mts` and `.cts`. Make sure they're supported by ESLint or an ESLint plugin.
286
286
 
287
287
  ### settings
288
288
 
@@ -317,7 +317,7 @@ Setting this to an object enables the resolver and passes the object as configur
317
317
 
318
318
  XO will automatically lint TypeScript files (`.ts`, `.mts`, `.cts`, `.d.ts` and `.tsx`) with the rules defined in [eslint-config-xo-typescript#use-with-xo](https://github.com/xojs/eslint-config-xo-typescript#use-with-xo).
319
319
 
320
- XO will handle the [@typescript-eslint/parser `project` option](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject) automatically even if you don't have a `tsconfig.json` in your project.
320
+ XO will handle the [@typescript-eslint/parser `project` option](https://typescript-eslint.io/packages/parser/#project) automatically even if you don't have a `tsconfig.json` in your project.
321
321
 
322
322
  ## GitHub Actions
323
323
 
@@ -384,7 +384,7 @@ If some files in your project are transpiled in order to support an older Node.j
384
384
 
385
385
  For example, if your project targets Node.js 8 but you want to use the latest JavaScript syntax as supported in Node.js 12:
386
386
  1. Set the `engines.node` property of your `package.json` to `>=8`
387
- 2. Configure [Babel](https://babeljs.io) to transpile your source files (in `src` directory in this example)
387
+ 2. Configure [Babel](https://babeljs.io) to transpile your source files (in `source` directory in this example)
388
388
  3. Make sure to include the transpiled files in your published package with the [`files`](https://docs.npmjs.com/files/package.json#files) and [`main`](https://docs.npmjs.com/files/package.json#main) properties of your `package.json`
389
389
  4. Configure the XO `overrides` option to set `nodeVersion` to `>=12` for your source files directory
390
390
 
@@ -394,14 +394,16 @@ For example, if your project targets Node.js 8 but you want to use the latest Ja
394
394
  "node": ">=12"
395
395
  },
396
396
  "scripts": {
397
- "build": "babel src --out-dir dist"
397
+ "build": "babel source --out-dir distribution"
398
398
  },
399
- "main": "dist/index.js",
400
- "files": ["dist/**/*.js"],
399
+ "main": "distribution/index.js",
400
+ "files": [
401
+ "distribution/**/*.js"
402
+ ],
401
403
  "xo": {
402
404
  "overrides": [
403
405
  {
404
- "files": "{src}/**/*.js",
406
+ "files": "source/**/*.js",
405
407
  "nodeVersion": ">=16"
406
408
  }
407
409
  ]