xo 0.59.3 → 0.61.0-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.
@@ -0,0 +1,39 @@
1
+ export const defaultIgnores = [
2
+ '**/node_modules/**',
3
+ '**/bower_components/**',
4
+ 'flow-typed/**',
5
+ 'coverage/**',
6
+ '{tmp,temp}/**',
7
+ '**/*.min.js',
8
+ 'vendor/**',
9
+ 'dist/**',
10
+ 'tap-snapshots/*.{cjs,js}',
11
+ ];
12
+ /**
13
+ List of options that values will be concatenanted during option merge.
14
+
15
+ Only applies to options defined as an Array.
16
+ */
17
+ export const tsExtensions = ['ts', 'tsx', 'cts', 'mts'];
18
+ export const jsExtensions = ['js', 'jsx', 'mjs', 'cjs'];
19
+ export const jsFilesGlob = `**/*.{${jsExtensions.join(',')}}`;
20
+ export const tsFilesGlob = `**/*.{${tsExtensions.join(',')}}`;
21
+ export const allExtensions = [...jsExtensions, ...tsExtensions];
22
+ export const allFilesGlob = `**/*.{${allExtensions.join(',')}}`;
23
+ export const moduleName = 'xo';
24
+ export const tsconfigDefaults = {
25
+ compilerOptions: {
26
+ target: 'es2022',
27
+ strict: true,
28
+ noImplicitReturns: true,
29
+ noImplicitOverride: true,
30
+ noUnusedLocals: true,
31
+ noUnusedParameters: true,
32
+ noFallthroughCasesInSwitch: true,
33
+ noUncheckedIndexedAccess: true,
34
+ noPropertyAccessFromIndexSignature: true,
35
+ noUncheckedSideEffectImports: true,
36
+ },
37
+ };
38
+ export const cacheDirName = 'xo-linter';
39
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B,oBAAoB;IACpB,wBAAwB;IACxB,eAAe;IACf,aAAa;IACb,eAAe;IACf,aAAa;IACb,WAAW;IACX,SAAS;IACT,0BAA0B;CAC1B,CAAC;AAEF;;;;EAIE;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAE9D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAEhE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,gBAAgB,GAAyB;IACrD,eAAe,EAAE;QAChB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,IAAI;QACZ,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,IAAI;QACxB,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,IAAI;QACxB,0BAA0B,EAAE,IAAI;QAChC,wBAAwB,EAAE,IAAI;QAC9B,kCAAkC,EAAE,IAAI;QACxC,4BAA4B,EAAE,IAAI;KAClC;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ This function checks if the files are matched by the tsconfig include, exclude, and it returns the unmatched files.
3
+
4
+ If no tsconfig is found, it will create a fallback tsconfig file in the `node_modules/.cache/xo` directory.
5
+
6
+ @param options
7
+ @returns The unmatched files.
8
+ */
9
+ export declare function handleTsconfig({ cwd, files }: {
10
+ cwd: string;
11
+ files: string[];
12
+ }): Promise<{
13
+ unincludedFiles: string[];
14
+ fallbackTsConfigPath: string;
15
+ }>;
@@ -0,0 +1,68 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs/promises';
3
+ import { getTsconfig } from 'get-tsconfig';
4
+ import micromatch from 'micromatch';
5
+ import { tsconfigDefaults, cacheDirName } from './constants.js';
6
+ const micromatchOptions = { matchBase: true };
7
+ /**
8
+ This function checks if the files are matched by the tsconfig include, exclude, and it returns the unmatched files.
9
+
10
+ If no tsconfig is found, it will create a fallback tsconfig file in the `node_modules/.cache/xo` directory.
11
+
12
+ @param options
13
+ @returns The unmatched files.
14
+ */
15
+ export async function handleTsconfig({ cwd, files }) {
16
+ const { config: tsConfig = tsconfigDefaults, path: tsConfigPath } = getTsconfig(cwd) ?? {};
17
+ tsConfig.compilerOptions ??= {};
18
+ const unincludedFiles = [];
19
+ for (const filePath of files) {
20
+ let hasMatch = false;
21
+ if (!tsConfigPath) {
22
+ unincludedFiles.push(filePath);
23
+ continue;
24
+ }
25
+ // If there is no files or include property - TS uses `**/*` as default so all TS files are matched.
26
+ // In tsconfig, excludes override includes - so we need to prioritize that matching logic.
27
+ if (tsConfig
28
+ && !tsConfig.include
29
+ && !tsConfig.files) {
30
+ // If we have an excludes property, we need to check it.
31
+ // If we match on excluded, then we definitively know that there is no tsconfig match.
32
+ if (Array.isArray(tsConfig.exclude)) {
33
+ const exclude = Array.isArray(tsConfig.exclude) ? tsConfig.exclude : [];
34
+ hasMatch = !micromatch.isMatch(filePath, exclude, micromatchOptions);
35
+ }
36
+ else {
37
+ // Not explicitly excluded and included by tsconfig defaults
38
+ hasMatch = true;
39
+ }
40
+ }
41
+ else {
42
+ // We have either and include or a files property in tsconfig
43
+ const include = Array.isArray(tsConfig.include) ? tsConfig.include : [];
44
+ const files = Array.isArray(tsConfig.files) ? tsConfig.files : [];
45
+ const exclude = Array.isArray(tsConfig.exclude) ? tsConfig.exclude : [];
46
+ // If we also have an exlcude we need to check all the arrays, (files, include, exclude)
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);
49
+ }
50
+ if (!hasMatch) {
51
+ unincludedFiles.push(filePath);
52
+ }
53
+ }
54
+ const fallbackTsConfigPath = path.join(cwd, 'node_modules', '.cache', cacheDirName, 'tsconfig.xo.json');
55
+ delete tsConfig.include;
56
+ delete tsConfig.exclude;
57
+ delete tsConfig.files;
58
+ tsConfig.files = unincludedFiles;
59
+ try {
60
+ await fs.mkdir(path.dirname(fallbackTsConfigPath), { recursive: true });
61
+ await fs.writeFile(fallbackTsConfigPath, JSON.stringify(tsConfig, null, 2));
62
+ }
63
+ catch (error) {
64
+ console.error(error);
65
+ }
66
+ return { unincludedFiles, fallbackTsConfigPath };
67
+ }
68
+ //# sourceMappingURL=handle-ts-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-ts-files.js","sourceRoot":"","sources":["../../lib/handle-ts-files.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,UAA0B,MAAM,YAAY,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE9D,MAAM,iBAAiB,GAAY,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC;AAErD;;;;;;;EAOE;AACF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAC,GAAG,EAAE,KAAK,EAAiC;IAChF,MAAM,EAAC,MAAM,EAAE,QAAQ,GAAG,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAC,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAEzF,QAAQ,CAAC,eAAe,KAAK,EAAE,CAAC;IAEhC,MAAM,eAAe,GAAa,EAAE,CAA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;YACxE,QAAQ,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,iBAAiB,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACjJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;IAExG,OAAO,QAAQ,CAAC,OAAO,CAAC;IACxB,OAAO,QAAQ,CAAC,OAAO,CAAC;IACxB,OAAO,QAAQ,CAAC,KAAK,CAAC;IAEtB,QAAQ,CAAC,KAAK,GAAG,eAAe,CAAC;IAEjC,IAAI,CAAC;QACJ,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QACtE,MAAM,EAAE,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type XoLintResult } from './types.js';
2
+ declare const openReport: (report: XoLintResult) => Promise<void>;
3
+ export default openReport;
@@ -0,0 +1,36 @@
1
+ import openEditor from 'open-editor';
2
+ const sortResults = (a, b) => a.errorCount + b.errorCount > 0 ? (a.errorCount - b.errorCount) : (a.warningCount - b.warningCount);
3
+ const resultToFile = (result) => {
4
+ const [message] = result.messages
5
+ .sort((a, b) => {
6
+ if (a.severity < b.severity) {
7
+ return 1;
8
+ }
9
+ if (a.severity > b.severity) {
10
+ return -1;
11
+ }
12
+ if (a.line < b.line) {
13
+ return -1;
14
+ }
15
+ if (a.line > b.line) {
16
+ return 1;
17
+ }
18
+ return 0;
19
+ });
20
+ return {
21
+ file: result.filePath,
22
+ line: message?.line,
23
+ column: message?.column,
24
+ };
25
+ };
26
+ const getFiles = (report, predicate) => report.results
27
+ .filter(result => predicate(result))
28
+ .sort(sortResults)
29
+ .map(result => resultToFile(result));
30
+ const openReport = async (report) => {
31
+ const count = report.errorCount > 0 ? 'errorCount' : 'warningCount';
32
+ const files = getFiles(report, result => result[count] > 0);
33
+ await openEditor(files);
34
+ };
35
+ export default openReport;
36
+ //# sourceMappingURL=open-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-report.js","sourceRoot":"","sources":["../../lib/open-report.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,MAAM,WAAW,GAAG,CAAC,CAAoB,EAAE,CAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC;AAExK,MAAM,YAAY,GAAG,CAAC,MAAyB,EAAE,EAAE;IAClD,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ;SAC/B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC7B,OAAO,CAAC,CAAC;QACV,CAAC;QAED,IAAI,CAAC,CAAC,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veXoConfig(options: LinterOptions): Promise<{
6
+ flatOptions: XoConfigItem[];
7
+ flatConfigPath: string;
8
+ }>;
9
+ export default resolveXoConfig;
@@ -0,0 +1,62 @@
1
+ import path from 'node:path';
2
+ import process from 'node:process';
3
+ import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
4
+ import pick from 'lodash.pick';
5
+ import arrify from 'arrify';
6
+ import { moduleName } from './constants.js';
7
+ /**
8
+ Finds the XO config file.
9
+ */
10
+ export async function resolveXoConfig(options) {
11
+ try {
12
+ options.cwd ||= process.cwd();
13
+ if (!path.isAbsolute(options.cwd)) {
14
+ options.cwd = path.resolve(process.cwd(), options.cwd);
15
+ }
16
+ const stopDirectory = path.dirname(options.cwd);
17
+ const flatConfigExplorer = cosmiconfig(moduleName, {
18
+ searchPlaces: [
19
+ 'package.json',
20
+ `${moduleName}.config.js`,
21
+ `${moduleName}.config.cjs`,
22
+ `${moduleName}.config.mjs`,
23
+ `${moduleName}.config.ts`,
24
+ `${moduleName}.config.cts`,
25
+ `${moduleName}.config.mts`,
26
+ ],
27
+ loaders: {
28
+ '.cts': defaultLoaders['.ts'], // eslint-disable-line @typescript-eslint/naming-convention
29
+ '.mts': defaultLoaders['.ts'], // eslint-disable-line @typescript-eslint/naming-convention
30
+ },
31
+ stopDir: stopDirectory,
32
+ cache: true,
33
+ });
34
+ options.filePath &&= path.resolve(options.cwd, options.filePath);
35
+ const searchPath = options.filePath ?? options.cwd;
36
+ let { config: flatOptions = [], filepath: flatConfigPath = '', } = await flatConfigExplorer.search(searchPath) ?? {};
37
+ const globalKeys = [
38
+ 'ignores',
39
+ 'settings',
40
+ 'parserOptions',
41
+ 'prettier',
42
+ 'semicolon',
43
+ 'space',
44
+ 'rules',
45
+ 'env',
46
+ 'extension',
47
+ 'files',
48
+ 'plugins',
49
+ 'react',
50
+ ];
51
+ flatOptions = arrify(flatOptions).map(config => pick(config, globalKeys));
52
+ return {
53
+ flatOptions,
54
+ flatConfigPath,
55
+ };
56
+ }
57
+ catch (error) {
58
+ throw new AggregateError([error], 'Error resolving XO config, there is likely an issue with your config file. Please check the file for mistakes.');
59
+ }
60
+ }
61
+ export default resolveXoConfig;
62
+ //# sourceMappingURL=resolve-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../../lib/resolve-config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAC,WAAW,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AACxD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE1C;;EAEE;AACF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAsB;IAI3D,IAAI,CAAC;QACJ,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC;QAE9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEhD,MAAM,kBAAkB,GAAG,WAAW,CAAC,UAAU,EAAE;YAClD,YAAY,EAAE;gBACb,cAAc;gBACd,GAAG,UAAU,YAAY;gBACzB,GAAG,UAAU,aAAa;gBAC1B,GAAG,UAAU,aAAa;gBAC1B,GAAG,UAAU,YAAY;gBACzB,GAAG,UAAU,aAAa;gBAC1B,GAAG,UAAU,aAAa;aAC1B;YACD,OAAO,EAAE;gBACR,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,2DAA2D;gBAC1F,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,2DAA2D;aAC1F;YACD,OAAO,EAAE,aAAa;YACtB,KAAK,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjE,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC;QAEnD,IAAI,EACH,MAAM,EAAE,WAAW,GAAG,EAAE,EACxB,QAAQ,EAAE,cAAc,GAAG,EAAE,GAC7B,GAAG,MAAO,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAmE,IAAI,EAAE,CAAC;QAEzH,MAAM,UAAU,GAAG;YAClB,SAAS;YACT,UAAU;YACV,eAAe;YACf,UAAU;YACV,WAAW;YACX,OAAO;YACP,OAAO;YACP,KAAK;YACL,WAAW;YACX,OAAO;YACP,SAAS;YACT,OAAO;SACP,CAAC;QAEF,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;QAE1E,OAAO;YACN,WAAW;YACX,cAAc;SACd,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,cAAc,CAAC,CAAC,KAAK,CAAC,EAAE,gHAAgH,CAAC,CAAC;IACrJ,CAAC;AACF,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,88 @@
1
+ import type { Simplify } from 'type-fest';
2
+ import { type ESLint, type Rule, type Linter } from 'eslint';
3
+ export type Space = boolean | number | string | undefined;
4
+ export type XoConfigOptions = {
5
+ /**
6
+ Use spaces for indentation.
7
+
8
+ Tabs are used if the value is `false`, otherwise the value is the number of spaces to use or true, the default number of spaces is 2.
9
+ */
10
+ space?: Space;
11
+ /**
12
+ Use semicolons at the end of statements or error for semi-colon usage.
13
+ */
14
+ semicolon?: boolean;
15
+ /**
16
+ Use Prettier to format code.
17
+
18
+ If `compat` is used, XO will not format with Prettier but will produce Prettier compatible code so Prettier can be used as a separate formatting tool.
19
+ */
20
+ prettier?: boolean | 'compat';
21
+ /**
22
+ Add React support.
23
+ */
24
+ react?: boolean;
25
+ /**
26
+ Files to ignore, can be a glob or array of globs.
27
+ */
28
+ ignores?: string | string[];
29
+ };
30
+ export type LinterOptions = {
31
+ /**
32
+ The current working directory to use for relative paths.
33
+ */
34
+ cwd: string;
35
+ /**
36
+ Write fixes to the files.
37
+ */
38
+ fix?: boolean;
39
+ /**
40
+ The path to the file being linted.
41
+ */
42
+ filePath?: string;
43
+ /**
44
+ If true, show only errors and NOT warnings. false by default.
45
+ */
46
+ quiet?: boolean;
47
+ /**
48
+ Auto-configure type aware linting on unincluded TS files.
49
+
50
+ Ensures that TypeScript files are linted with the type-aware parser even if they are not explicitly included in the tsconfig.
51
+
52
+ @private
53
+ */
54
+ ts?: boolean;
55
+ };
56
+ export type LintTextOptions = {
57
+ /**
58
+ The path to the file being linted.
59
+ */
60
+ filePath: string;
61
+ /**
62
+ Warn if the file is ignored.
63
+ */
64
+ warnIgnored?: boolean;
65
+ };
66
+ export type XoConfigItem = Simplify<XoConfigOptions & Omit<Linter.Config, 'files' | 'ignores'> & {
67
+ /**
68
+ An array of glob patterns indicating the files that the configuration object should apply to. If not specified, the configuration object applies to all files.
69
+
70
+ @see [Ignore Patterns](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#excluding-files-with-ignores)
71
+ */
72
+ files?: string | string[] | undefined;
73
+ /**
74
+ An array of glob patterns indicating the files that the configuration object should not apply to. If not specified, the configuration object applies to all files matched by files.
75
+
76
+ @see [Ignore Patterns](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#excluding-files-with-ignores)
77
+ */
78
+ ignores?: string | string[] | undefined;
79
+ }>;
80
+ export type FlatXoConfig = XoConfigItem | XoConfigItem[];
81
+ export type XoLintResult = {
82
+ errorCount: number;
83
+ warningCount: number;
84
+ fixableErrorCount: number;
85
+ fixableWarningCount: number;
86
+ results: ESLint.LintResult[];
87
+ rulesMeta: Record<string, Rule.RuleMetaData>;
88
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { type SetRequired } from 'type-fest';
2
+ import { type Linter } from 'eslint';
3
+ import { type XoConfigItem } from './types.js';
4
+ /**
5
+ Convert a `xo` config item to an ESLint config item.
6
+
7
+ In a flat structure these config items represent the config object items.
8
+
9
+ Files and rules will always be defined and all other ESLint config properties are preserved.
10
+
11
+ @param xoConfig
12
+ @returns eslintConfig
13
+ */
14
+ export declare const xoToEslintConfigItem: (xoConfig: XoConfigItem) => SetRequired<Linter.Config, "rules" | "files">;
@@ -0,0 +1,23 @@
1
+ import arrify from 'arrify';
2
+ import { allFilesGlob } from './constants.js';
3
+ /**
4
+ Convert a `xo` config item to an ESLint config item.
5
+
6
+ In a flat structure these config items represent the config object items.
7
+
8
+ Files and rules will always be defined and all other ESLint config properties are preserved.
9
+
10
+ @param xoConfig
11
+ @returns eslintConfig
12
+ */
13
+ export const xoToEslintConfigItem = (xoConfig) => {
14
+ const { files, rules, space, prettier, ignores, semicolon, react, ..._xoConfig } = xoConfig;
15
+ const eslintConfig = {
16
+ ..._xoConfig,
17
+ files: arrify(xoConfig.files ?? allFilesGlob),
18
+ rules: xoConfig.rules ?? {},
19
+ };
20
+ eslintConfig.ignores &&= arrify(xoConfig.ignores);
21
+ return eslintConfig;
22
+ };
23
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C;;;;;;;;;EASE;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAsB,EAAiD,EAAE;IAC7G,MAAM,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,GAAG,SAAS,EACZ,GAAG,QAAQ,CAAC;IAEb,MAAM,YAAY,GAAkD;QACnE,GAAG,SAAS;QACZ,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,YAAY,CAAC;QAC7C,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;KAC3B,CAAC;IAEF,YAAY,CAAC,OAAO,KAAK,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type Linter } from 'eslint';
2
+ import { type Options } from 'prettier';
3
+ import { type XoConfigItem } from './types.js';
4
+ export type CreateConfigOptions = {
5
+ prettierOptions?: Options;
6
+ };
7
+ /**
8
+ Takes a XO flat config and returns an ESlint flat config.
9
+ */
10
+ export declare function xoToEslintConfig(flatXoConfig: XoConfigItem[] | undefined, { prettierOptions }?: CreateConfigOptions): Promise<Linter.Config[]>;
11
+ export default xoToEslintConfig;
@@ -0,0 +1,106 @@
1
+ /* eslint-disable complexity */
2
+ import configXoTypescript from 'eslint-config-xo-typescript';
3
+ import arrify from 'arrify';
4
+ import configReact from 'eslint-config-xo-react';
5
+ import pluginPrettier from 'eslint-plugin-prettier';
6
+ import eslintConfigPrettier from 'eslint-config-prettier';
7
+ import { config } from './config.js';
8
+ import { xoToEslintConfigItem } from './utils.js';
9
+ /**
10
+ Takes a XO flat config and returns an ESlint flat config.
11
+ */
12
+ export async function xoToEslintConfig(flatXoConfig, { prettierOptions = {} } = {}) {
13
+ const baseConfig = [...config];
14
+ /**
15
+ Since configs are merged and the last config takes precedence this means we need to handle both true AND false cases for each option. For example, we need to turn `prettier`, `space`, `semi`, etc. on or off for a specific file.
16
+ */
17
+ for (const xoConfigItem of flatXoConfig ?? []) {
18
+ const keysOfXoConfig = Object.keys(xoConfigItem);
19
+ if (keysOfXoConfig.length === 0) {
20
+ continue;
21
+ }
22
+ /** Special case global ignores */
23
+ if (keysOfXoConfig.length === 1 && keysOfXoConfig[0] === 'ignores') {
24
+ baseConfig.push({ ignores: arrify(xoConfigItem.ignores) });
25
+ continue;
26
+ }
27
+ /**
28
+ An ESLint config item derived from the XO config item with rules and files initialized.
29
+ */
30
+ const eslintConfigItem = xoToEslintConfigItem(xoConfigItem);
31
+ if (xoConfigItem.semicolon === false) {
32
+ eslintConfigItem.rules['@stylistic/semi'] = ['error', 'never'];
33
+ eslintConfigItem.rules['@stylistic/semi-spacing'] = [
34
+ 'error',
35
+ { before: false, after: true },
36
+ ];
37
+ }
38
+ if (xoConfigItem.space) {
39
+ const spaces = typeof xoConfigItem.space === 'number' ? xoConfigItem.space : 2;
40
+ eslintConfigItem.rules['@stylistic/indent'] = [
41
+ 'error',
42
+ spaces,
43
+ // eslint-disable-next-line @typescript-eslint/naming-convention
44
+ { SwitchCase: 1 },
45
+ ];
46
+ }
47
+ else if (xoConfigItem.space === false) {
48
+ // If a user sets this to false for a small subset of files for some reason,
49
+ // then we need to set them back to their original values.
50
+ eslintConfigItem.rules['@stylistic/indent'] = configXoTypescript[1]?.rules?.['@stylistic/indent'];
51
+ }
52
+ if (xoConfigItem.prettier) {
53
+ if (xoConfigItem.prettier === 'compat') {
54
+ baseConfig.push({ ...eslintConfigPrettier, files: eslintConfigItem.files });
55
+ }
56
+ else {
57
+ // Validate that Prettier options match other `xoConfig` options.
58
+ if ((xoConfigItem.semicolon && prettierOptions.semi === false) ?? (!xoConfigItem.semicolon && prettierOptions.semi === true)) {
59
+ throw new Error(`The Prettier config \`semi\` is ${prettierOptions.semi} while Xo \`semicolon\` is ${xoConfigItem.semicolon}, also check your .editorconfig for inconsistencies.`);
60
+ }
61
+ if (((xoConfigItem.space ?? typeof xoConfigItem.space === 'number') && prettierOptions.useTabs === true) || (!xoConfigItem.space && prettierOptions.useTabs === false)) {
62
+ throw new Error(`The Prettier config \`useTabs\` is ${prettierOptions.useTabs} while Xo \`space\` is ${xoConfigItem.space}, also check your .editorconfig for inconsistencies.`);
63
+ }
64
+ if (typeof xoConfigItem.space === 'number' && typeof prettierOptions.tabWidth === 'number' && xoConfigItem.space !== prettierOptions.tabWidth) {
65
+ throw new Error(`The Prettier config \`tabWidth\` is ${prettierOptions.tabWidth} while Xo \`space\` is ${xoConfigItem.space}, also check your .editorconfig for inconsistencies.`);
66
+ }
67
+ // Add Prettier plugin
68
+ eslintConfigItem.plugins = {
69
+ ...eslintConfigItem.plugins,
70
+ prettier: pluginPrettier,
71
+ };
72
+ const prettierConfig = {
73
+ singleQuote: true,
74
+ bracketSpacing: false,
75
+ bracketSameLine: false,
76
+ trailingComma: 'all',
77
+ tabWidth: typeof xoConfigItem.space === 'number' ? xoConfigItem.space : 2,
78
+ useTabs: !xoConfigItem.space,
79
+ semi: xoConfigItem.semicolon,
80
+ ...prettierOptions,
81
+ };
82
+ // Configure Prettier rules
83
+ const rulesWithPrettier = {
84
+ ...eslintConfigItem.rules,
85
+ ...pluginPrettier.configs?.['recommended']?.rules,
86
+ // eslint-disable-next-line @typescript-eslint/naming-convention
87
+ 'prettier/prettier': ['error', prettierConfig],
88
+ ...eslintConfigPrettier.rules,
89
+ };
90
+ eslintConfigItem.rules = rulesWithPrettier;
91
+ }
92
+ }
93
+ else if (xoConfigItem.prettier === false) {
94
+ // Turn Prettier off for a subset of files
95
+ eslintConfigItem.rules['prettier/prettier'] = 'off';
96
+ }
97
+ if (xoConfigItem.react) {
98
+ // Ensure the files applied to the React config are the same as the config they are derived from
99
+ baseConfig.push({ ...configReact[0], files: eslintConfigItem.files });
100
+ }
101
+ baseConfig.push(eslintConfigItem);
102
+ }
103
+ return baseConfig;
104
+ }
105
+ export default xoToEslintConfig;
106
+ //# sourceMappingURL=xo-to-eslint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xo-to-eslint.js","sourceRoot":"","sources":["../../lib/xo-to-eslint.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,WAAW,MAAM,wBAAwB,CAAC;AAEjD,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAMhD;;EAEE;AACF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,YAAwC,EAAE,EAAC,eAAe,GAAG,EAAE,KAAyB,EAAE;IAChI,MAAM,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAE/B;;MAEE;IACF,KAAK,MAAM,YAAY,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEjD,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,SAAS;QACV,CAAC;QAED,kCAAkC;QAClC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACpE,UAAU,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC;YACzD,SAAS;QACV,CAAC;QAED;;UAEE;QACF,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;QAE5D,IAAI,YAAY,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;YACtC,gBAAgB,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AAG,gBAAgB,CAAC,KAAK;oBACzB,GAAI,cAAc,CAAC,OAAO,EAAE,CAAC,aAAa,CAAuB,EAAE,KAAK;oBACxE,gEAAgE;oBAChE,mBAAmB,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC;oBAC9C,GAAG,oBAAoB,CAAC,KAAK;iBAC7B,CAAC;gBAEF,gBAAgB,CAAC,KAAK,GAAG,iBAAiB,CAAC;YAC5C,CAAC;QACF,CAAC;aAAM,IAAI,YAAY,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC5C,0CAA0C;YAC1C,gBAAgB,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,KAAK,CAAC;QACrD,CAAC;QAED,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;YACxB,gGAAgG;YAChG,UAAU,CAAC,IAAI,CAAC,EAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAC,CAAC,CAAC;QACrE,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { ESLint, type Linter } from 'eslint';
2
+ import prettier from 'prettier';
3
+ import { type XoLintResult, type LinterOptions, type LintTextOptions, type XoConfigOptions, type XoConfigItem } from './types.js';
4
+ import { xoToEslintConfig } from './xo-to-eslint.js';
5
+ export declare class Xo {
6
+ /**
7
+ Static helper to convert an XO config to an ESLint config to be used in `eslint.config.js`.
8
+ */
9
+ static xoToEslintConfig: typeof xoToEslintConfig;
10
+ /**
11
+ Static helper for backwards compatibility and use in editor extensions and other tools.
12
+ */
13
+ static lintText(code: string, options: LintTextOptions & LinterOptions & XoConfigOptions): Promise<XoLintResult>;
14
+ /**
15
+ Static helper for backwards compatibility and use in editor extensions and other tools.
16
+ */
17
+ static lintFiles(globs: string | undefined, options: LinterOptions & XoConfigOptions): Promise<XoLintResult>;
18
+ /**
19
+ Write the fixes to disk.
20
+ */
21
+ static outputFixes(results: XoLintResult): Promise<void>;
22
+ /**
23
+ Required linter options: `cwd`, `fix`, and `filePath` (in case of `lintText`).
24
+ */
25
+ linterOptions: LinterOptions;
26
+ /**
27
+ Base XO config options that allow configuration from CLI or other sources. Not to be confused with the `xoConfig` property which is the resolved XO config from the flat config AND base config.
28
+ */
29
+ baseXoConfig: XoConfigOptions;
30
+ /**
31
+ File path to the ESLint cache.
32
+ */
33
+ cacheLocation: string;
34
+ /**
35
+ A re-usable ESLint instance configured with options calculated from the XO config.
36
+ */
37
+ eslint?: ESLint;
38
+ /**
39
+ XO config derived from both the base config and the resolved flat config.
40
+ */
41
+ xoConfig?: XoConfigItem[];
42
+ /**
43
+ The ESLint config calculated from the resolved XO config.
44
+ */
45
+ eslintConfig?: Linter.Config[];
46
+ /**
47
+ The flat XO config path, if there is one.
48
+ */
49
+ flatConfigPath?: string | undefined;
50
+ /**
51
+ If any user configs container Prettier, we will need to fetch the Prettier config.
52
+ */
53
+ prettier?: boolean;
54
+ /**
55
+ The Prettier config if it exists and is needed.
56
+ */
57
+ prettierConfig?: prettier.Options;
58
+ constructor(_linterOptions: LinterOptions, _baseXoConfig?: XoConfigOptions);
59
+ /**
60
+ Sets the XO config on the XO instance.
61
+
62
+ @private
63
+ */
64
+ setXoConfig(): Promise<void>;
65
+ /**
66
+ Sets the ESLint config on the XO instance.
67
+
68
+ @private
69
+ */
70
+ setEslintConfig(): Promise<void>;
71
+ /**
72
+ Sets the ignores on the XO instance.
73
+
74
+ @private
75
+ */
76
+ setIgnores(): void;
77
+ /**
78
+ Checks every TS file to ensure its included in the tsconfig and any that are not included are added to a generated tsconfig for type aware linting.
79
+
80
+ @param files - The TypeScript files being linted.
81
+ */
82
+ handleUnincludedTsFiles(files?: string[]): Promise<void>;
83
+ /**
84
+ Initializes the ESLint instance on the XO instance.
85
+ */
86
+ initEslint(files?: string[]): Promise<void>;
87
+ /**
88
+ Lints the files on the XO instance.
89
+
90
+ @param globs - Glob pattern to pass to `globby`.
91
+ @throws Error
92
+ */
93
+ lintFiles(globs?: string | string[]): Promise<XoLintResult>;
94
+ /**
95
+ Lints the text on the XO instance.
96
+ */
97
+ lintText(code: string, lintTextOptions: LintTextOptions): Promise<XoLintResult>;
98
+ calculateConfigForFile(filePath: string): Promise<Linter.Config>;
99
+ getFormatter(name: string): Promise<ESLint.LoadedFormatter>;
100
+ private processReport;
101
+ private getReportStatistics;
102
+ }
103
+ export default Xo;