Skip to content

Commit

Permalink
Update dependencies (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Jul 1, 2021
1 parent 41c8f39 commit 0a752c7
Show file tree
Hide file tree
Showing 15 changed files with 274 additions and 277 deletions.
41 changes: 21 additions & 20 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,70 +45,71 @@ const cli = meow(`
- Add XO to your project with \`npm init xo\`.
- Put options in package.json instead of using flags so other tools can read it.
`, {
importMeta: import.meta,
autoVersion: false,
booleanDefault: undefined,
flags: {
fix: {
type: 'boolean'
type: 'boolean',
},
reporter: {
type: 'string'
type: 'string',
},
env: {
type: 'string',
isMultiple: true
isMultiple: true,
},
global: {
type: 'string',
isMultiple: true
isMultiple: true,
},
ignore: {
type: 'string',
isMultiple: true
isMultiple: true,
},
space: {
type: 'string'
type: 'string',
},
semicolon: {
type: 'boolean'
type: 'boolean',
},
prettier: {
type: 'boolean'
type: 'boolean',
},
nodeVersion: {
type: 'string'
type: 'string',
},
plugin: {
type: 'string',
isMultiple: true
isMultiple: true,
},
extend: {
type: 'string',
isMultiple: true
isMultiple: true,
},
open: {
type: 'boolean'
type: 'boolean',
},
quiet: {
type: 'boolean'
type: 'boolean',
},
extension: {
type: 'string',
isMultiple: true
isMultiple: true,
},
cwd: {
type: 'string'
type: 'string',
},
printConfig: {
type: 'string'
type: 'string',
},
stdin: {
type: 'boolean'
type: 'boolean',
},
stdinFilename: {
type: 'string'
}
}
type: 'string',
},
},
});

const {input, flags: options, showVersion} = cli;
Expand Down
34 changes: 17 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import {
mergeWithFileConfig,
mergeWithFileConfigs,
buildConfig,
mergeOptions
mergeOptions,
} from './lib/options-manager.js';

/** Merge multiple reports into a single report */
const mergeReports = reports => {
const report = {
results: [],
errorCount: 0,
warningCount: 0
warningCount: 0,
};

for (const currentReport of reports) {
Expand All @@ -41,7 +41,7 @@ const getReportStatistics = results => {
errorCount: 0,
warningCount: 0,
fixableErrorCount: 0,
fixableWarningCount: 0
fixableWarningCount: 0,
};

for (const result of results) {
Expand All @@ -61,7 +61,7 @@ const processReport = (report, {isQuiet = false} = {}) => {

const result = {
results: report,
...getReportStatistics(report)
...getReportStatistics(report),
};

defineLazyProperty(result, 'usedDeprecatedRules', () => {
Expand Down Expand Up @@ -95,7 +95,7 @@ const runEslint = async (paths, options, processorOptions) => {
const globFiles = async (patterns, {ignores, extensions, cwd}) => (
await globby(
patterns.length === 0 ? [`**/*.{${extensions.join(',')}}`] : arrify(patterns),
{ignore: ignores, gitignore: true, cwd}
{ignore: ignores, gitignore: true, cwd},
)).filter(file => extensions.includes(path.extname(file).slice(1))).map(file => path.resolve(cwd, file));

const getConfig = async options => {
Expand All @@ -120,9 +120,9 @@ const lintText = async (string, inputOptions = {}) => {
const filename = path.relative(options.cwd, filePath);

if (
micromatch.isMatch(filename, options.baseConfig.ignorePatterns) ||
globby.gitignore.sync({cwd: options.cwd, ignore: options.baseConfig.ignorePatterns})(filePath) ||
await engine.isPathIgnored(filePath)
micromatch.isMatch(filename, options.baseConfig.ignorePatterns)
|| globby.gitignore.sync({cwd: options.cwd, ignore: options.baseConfig.ignorePatterns})(filePath)
|| await engine.isPathIgnored(filePath)
) {
return {
errorCount: 0,
Expand All @@ -131,8 +131,8 @@ const lintText = async (string, inputOptions = {}) => {
errorCount: 0,
filePath: filename,
messages: [],
warningCount: 0
}]
warningCount: 0,
}],
};
}
}
Expand All @@ -149,17 +149,17 @@ const lintFiles = async (patterns, inputOptions = {}) => {
const configFiles = (await Promise.all(
(await globby(
CONFIG_FILES.map(configFile => `**/${configFile}`),
{ignore: DEFAULT_IGNORES, gitignore: true, cwd: inputOptions.cwd}
)).map(async configFile => configExplorer.load(path.resolve(inputOptions.cwd, configFile)))
{ignore: DEFAULT_IGNORES, gitignore: true, cwd: inputOptions.cwd},
)).map(async configFile => configExplorer.load(path.resolve(inputOptions.cwd, configFile))),
)).filter(Boolean);

const paths = configFiles.length > 0 ?
await pReduce(
const paths = configFiles.length > 0
? await pReduce(
configFiles,
async (paths, {filepath, config}) =>
[...paths, ...(await globFiles(patterns, {...mergeOptions(inputOptions, config), cwd: path.dirname(filepath)}))],
[]) :
await globFiles(patterns, mergeOptions(inputOptions));
[])
: await globFiles(patterns, mergeOptions(inputOptions));

return mergeReports(await pMap(await mergeWithFileConfigs([...new Set(paths)], inputOptions, configFiles), async ({files, options, prettierOptions}) => runEslint(files, buildConfig(options, prettierOptions), {isQuiet: options.quiet})));
};
Expand All @@ -175,5 +175,5 @@ export default {
outputFixes: async ({results}) => ESLint.outputFixes(results),
getConfig,
lintText,
lintFiles
lintFiles,
};
50 changes: 25 additions & 25 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const DEFAULT_IGNORES = [
'**/*.min.js',
'vendor/**',
'dist/**',
'tap-snapshots/*.{cjs,js}'
'tap-snapshots/*.{cjs,js}',
];

/**
Expand All @@ -18,20 +18,20 @@ const MERGE_OPTIONS_CONCAT = [
'extends',
'envs',
'globals',
'plugins'
'plugins',
];

const TYPESCRIPT_EXTENSION = [
'ts',
'tsx'
'tsx',
];

const DEFAULT_EXTENSION = [
'js',
'jsx',
'mjs',
'cjs',
...TYPESCRIPT_EXTENSION
...TYPESCRIPT_EXTENSION,
];

/**
Expand Down Expand Up @@ -60,57 +60,57 @@ With `engines.node` set to `>=8` the rule `plugin/rule` will be used with the co
*/
const ENGINE_RULES = {
'unicorn/prefer-spread': {
'5.0.0': 'off'
'5.0.0': 'off',
},
'unicorn/no-new-buffer': {
'5.10.0': 'off'
'5.10.0': 'off',
},
'prefer-rest-params': {
'6.0.0': 'off'
'6.0.0': 'off',
},
'prefer-destructuring': {
'6.0.0': 'off'
'6.0.0': 'off',
},
'promise/prefer-await-to-then': {
'7.6.0': 'off'
'7.6.0': 'off',
},
'prefer-object-spread': {
'8.3.0': 'off'
'8.3.0': 'off',
},
'node/prefer-global/url-search-params': {
'10.0.0': 'off'
'10.0.0': 'off',
},
'node/prefer-global/url': {
'10.0.0': 'off'
'10.0.0': 'off',
},
'no-useless-catch': {
'10.0.0': 'off'
'10.0.0': 'off',
},
'prefer-named-capture-group': {
'10.0.0': 'off'
'10.0.0': 'off',
},
'node/prefer-global/text-encoder': {
'11.0.0': 'off'
'11.0.0': 'off',
},
'node/prefer-global/text-decoder': {
'11.0.0': 'off'
'11.0.0': 'off',
},
'unicorn/prefer-flat-map': {
'11.0.0': 'off'
'11.0.0': 'off',
},
'node/prefer-promises/dns': {
'11.14.0': 'off'
'11.14.0': 'off',
},
'node/prefer-promises/fs': {
'11.14.0': 'off'
}
'11.14.0': 'off',
},
};

const PRETTIER_CONFIG_OVERRIDE = {
'eslint-plugin-babel': 'prettier/babel',
'eslint-plugin-flowtype': 'prettier/flowtype',
'eslint-plugin-standard': 'prettier/standard',
'eslint-plugin-vue': 'prettier/vue'
'eslint-plugin-vue': 'prettier/vue',
};

const MODULE_NAME = 'xo';
Expand All @@ -122,7 +122,7 @@ const CONFIG_FILES = [
`.${MODULE_NAME}-config.js`,
`.${MODULE_NAME}-config.cjs`,
`${MODULE_NAME}.config.js`,
`${MODULE_NAME}.config.cjs`
`${MODULE_NAME}.config.cjs`,
];

const TSCONFIG_DEFAULTS = {
Expand All @@ -133,8 +133,8 @@ const TSCONFIG_DEFAULTS = {
noImplicitReturns: true,
noUnusedLocals: true,
noUnusedParameters: true,
noFallthroughCasesInSwitch: true
}
noFallthroughCasesInSwitch: true,
},
};

const CACHE_DIR_NAME = 'xo-linter';
Expand All @@ -149,5 +149,5 @@ export {
CONFIG_FILES,
MERGE_OPTIONS_CONCAT,
TSCONFIG_DEFAULTS,
CACHE_DIR_NAME
CACHE_DIR_NAME,
};
3 changes: 2 additions & 1 deletion lib/open-report.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
import openEditor from 'open-editor';

const sortResults = (a, b) => a.errorCount + b.errorCount > 0 ? (a.errorCount - b.errorCount) : (a.warningCount - b.warningCount);
Expand Down Expand Up @@ -27,7 +28,7 @@ const resultToFile = result => {
return {
file: result.filePath,
line: message.line,
column: message.column
column: message.column,
};
};

Expand Down
Loading

0 comments on commit 0a752c7

Please sign in to comment.