Comparing version
@@ -6,2 +6,16 @@ # Change Log | ||
# [6.0.0](https://github.com/4Catalyzer/cli/compare/pedantic@5.1.3...pedantic@6.0.0) (2021-09-17) | ||
* feat!: convert to ESM (#318) ([5862163](https://github.com/4Catalyzer/cli/commit/58621632fc3961f3ed24eeddc4342645b8b5673b)), closes [#318](https://github.com/4Catalyzer/cli/issues/318) | ||
### BREAKING CHANGES | ||
* the codebase has migrated to native ESM which requires node 12+ and may cause issues downstream | ||
## [5.1.3](https://github.com/4Catalyzer/cli/compare/pedantic@5.1.2...pedantic@5.1.3) (2021-09-16) | ||
@@ -8,0 +22,0 @@ |
12
cli.js
#!/usr/bin/env node | ||
const yargs = require('yargs'); | ||
import Yargs from 'yargs'; | ||
import format from './format.js'; | ||
import lint from './lint.js'; | ||
const yargs = Yargs(process.argv.slice(2)); | ||
yargs | ||
.help() | ||
.alias('h', 'help') | ||
@@ -12,4 +16,4 @@ .version() | ||
.strict() | ||
.command(require('./format')) | ||
.command(require('./lint')) | ||
.command(format) | ||
.command(lint) | ||
.parse(process.argv.slice(2)); |
@@ -1,2 +0,2 @@ | ||
const prettier = require('prettier'); | ||
import prettier from 'prettier'; | ||
@@ -32,2 +32,2 @@ class Formatter { | ||
module.exports = Formatter; | ||
export default Formatter; |
@@ -1,9 +0,9 @@ | ||
const format = require('./lib'); | ||
import format from './lib.js'; | ||
exports.command = '$0 <patterns..>'; | ||
export const command = '$0 <patterns..>'; | ||
exports.describe = 'Format files'; | ||
export const describe = 'Format files'; | ||
exports.builder = (_) => | ||
_.option('write', { | ||
export function builder(_) { | ||
return _.option('write', { | ||
type: 'boolean', | ||
@@ -24,4 +24,5 @@ default: true, | ||
}); | ||
} | ||
exports.handler = async (argv) => { | ||
export async function handler(argv) { | ||
const { _, patterns, write, withNodeModules, ...options } = argv; | ||
@@ -35,2 +36,2 @@ | ||
}); | ||
}; | ||
} |
29
lib.js
@@ -1,15 +0,15 @@ | ||
const { promises: fs } = require('fs'); | ||
const path = require('path'); | ||
const { debuglog } = require('util'); | ||
import { promises as fs } from 'fs'; | ||
import { relative } from 'path'; | ||
import { debuglog } from 'util'; | ||
const ArgUtilities = require('@4c/cli-core/ArgUtilities'); | ||
const { | ||
import { resolveFilePatterns } from '@4c/cli-core/ArgUtilities'; | ||
import { | ||
chalk, | ||
spinner, | ||
chalk, | ||
stripAnsi, | ||
table, | ||
} = require('@4c/cli-core/ConsoleUtilities'); | ||
} from '@4c/cli-core/ConsoleUtilities'; | ||
const FileFormatter = require('./FileFormatter'); | ||
const Linter = require('./Linter'); | ||
import FileFormatter from './FileFormatter.js'; | ||
import Linter from './Linter.js'; | ||
@@ -24,3 +24,3 @@ const debug = debuglog('pedantic'); | ||
*/ | ||
module.exports = async ( | ||
export default async ( | ||
filePatterns, | ||
@@ -41,3 +41,3 @@ { | ||
const filePaths = await ArgUtilities.resolveFilePatterns(filePatterns, { | ||
const filePaths = await resolveFilePatterns(filePatterns, { | ||
cwd, | ||
@@ -97,3 +97,3 @@ ignoreNodeModules, | ||
progress.text = chalk.dim(path.relative(cwd, filePath)); | ||
progress.text = chalk.dim(relative(cwd, filePath)); | ||
@@ -139,6 +139,3 @@ if (fix) { | ||
output += `${table( | ||
needsFormatting.map((filePath) => [ | ||
'', | ||
path.relative(cwd, filePath).trim(), | ||
]), | ||
needsFormatting.map((filePath) => ['', relative(cwd, filePath).trim()]), | ||
{ | ||
@@ -145,0 +142,0 @@ align: ['', 'l'], |
15
lint.js
@@ -1,9 +0,9 @@ | ||
const format = require('./lib'); | ||
import format from './lib.js'; | ||
exports.command = '$0 <patterns..>'; | ||
export const command = '$0 <patterns..>'; | ||
exports.describe = 'Lint files use ESLint and prettier'; | ||
export const describe = 'Lint files use ESLint and prettier'; | ||
exports.builder = (_) => | ||
_.option('fix', { | ||
export function builder(_) { | ||
return _.option('fix', { | ||
type: 'boolean', | ||
@@ -29,4 +29,5 @@ default: false, | ||
}); | ||
} | ||
exports.handler = async (argv) => { | ||
export async function handler(argv) { | ||
const { _, patterns, fix, withWarnings, withNodeModules, ...options } = argv; | ||
@@ -41,2 +42,2 @@ | ||
}); | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
const { ESLint } = require('eslint'); | ||
import eslint from 'eslint'; | ||
@@ -11,3 +11,3 @@ class Linter { | ||
this.#eslint = new ESLint({ cwd, fix }); | ||
this.#eslint = new eslint.ESLint({ cwd, fix }); | ||
this.#results = []; | ||
@@ -57,2 +57,2 @@ | ||
module.exports = Linter; | ||
export default Linter; |
{ | ||
"name": "pedantic", | ||
"version": "5.1.3", | ||
"version": "6.0.0", | ||
"homepage": "https://github.com/4Catalyzer/cli/tree/master/packages/rollout", | ||
@@ -11,5 +11,13 @@ "bugs": { | ||
"main": "lib.js", | ||
"type": "module", | ||
"bin": { | ||
"pedantic": "cli.js" | ||
}, | ||
"exports": { | ||
".": "./lib.js", | ||
"./lint": "./lint.js", | ||
"./lint.js": "./lint.js", | ||
"./format": "./format.js", | ||
"./format.js": "./format.js" | ||
}, | ||
"repository": { | ||
@@ -21,13 +29,16 @@ "type": "git", | ||
"scripts": { | ||
"test": "jest" | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest" | ||
}, | ||
"jest": { | ||
"preset": "@4c/jest-preset", | ||
"testEnvironment": "node" | ||
"testEnvironment": "node", | ||
"transformIgnorePatterns": [ | ||
".*" | ||
], | ||
"transform": {} | ||
}, | ||
"dependencies": { | ||
"@4c/cli-core": "^2.3.0", | ||
"@4c/cli-core": "^3.0.0", | ||
"eslint": "^7.32.0", | ||
"prettier": "^2.4.1", | ||
"yargs": "^16.2.0" | ||
"yargs": "^17.1.1" | ||
}, | ||
@@ -41,3 +52,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "d38e190b4fd6ecd1023f6f0f26ae0435d647ec82" | ||
"gitHead": "39128f0407abab61238107e61c3b2d58ad920936" | ||
} |
@@ -1,7 +0,8 @@ | ||
const path = require('path'); | ||
import { dirname, resolve } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
const pedantic = require('../lib'); | ||
import pedantic from '../lib.js'; | ||
describe('pedantic', () => { | ||
const cwd = path.resolve(__dirname, './fixtures'); | ||
const cwd = resolve(dirname(fileURLToPath(import.meta.url)), './fixtures'); | ||
it('should', async () => { | ||
@@ -8,0 +9,0 @@ await pedantic(['**/*.js'], { cwd }); |
19928
4.12%318
0.63%Yes
NaN+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated