Comparing version 7.0.0 to 7.0.1
82
index.js
@@ -28,13 +28,7 @@ #!/usr/bin/env node | ||
'[ecmaVersion]', | ||
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019' | ||
'ecmaVersion to check files against. Can be: es3, es4, es5, es6/es2015, es7/es2016, es8/es2017, es9/es2018, es10/es2019', | ||
) | ||
.argument( | ||
'[files...]', | ||
'a glob of files to to test the EcmaScript version against' | ||
) | ||
.argument('[files...]', 'a glob of files to to test the EcmaScript version against') | ||
.option('--module', 'use ES modules') | ||
.option( | ||
'--allow-hash-bang', | ||
'if the code starts with #! treat it as a comment' | ||
) | ||
.option('--allow-hash-bang', 'if the code starts with #! treat it as a comment') | ||
.option('--not <files>', 'folder or file names to skip') | ||
@@ -46,14 +40,16 @@ .option('--no-color', 'disable use of colors in output') | ||
'--silent', | ||
'silent mode: does not output anything, giving no indication of success or failure other than the exit code' | ||
'silent mode: does not output anything, giving no indication of success or failure other than the exit code', | ||
) | ||
.action((ecmaVersionArg, filesArg, options) => { | ||
const logger = winston.createLogger() | ||
logger.add(new winston.transports.Console({ | ||
silent: options.silent, | ||
level: options.verbose ? 'silly' : options.quiet ? 'warn' : 'info', | ||
format: winston.format.combine( | ||
...supportsColor.stdout ? [winston.format.colorize()] : [], | ||
winston.format.simple() | ||
) | ||
})) | ||
logger.add( | ||
new winston.transports.Console({ | ||
silent: options.silent, | ||
level: options.verbose ? 'silly' : options.quiet ? 'warn' : 'info', | ||
format: winston.format.combine( | ||
...(supportsColor.stdout ? [winston.format.colorize()] : []), | ||
winston.format.simple(), | ||
), | ||
}), | ||
) | ||
@@ -68,22 +64,12 @@ const configFilePath = path.resolve(process.cwd(), '.escheckrc') | ||
*/ | ||
const config = fs.existsSync(configFilePath) | ||
? JSON.parse(fs.readFileSync(configFilePath)) | ||
: {} | ||
const expectedEcmaVersion = ecmaVersionArg | ||
? ecmaVersionArg | ||
: config.ecmaVersion | ||
const files = | ||
filesArg && filesArg.length ? filesArg : [].concat(config.files) | ||
const config = fs.existsSync(configFilePath) ? JSON.parse(fs.readFileSync(configFilePath)) : {} | ||
const expectedEcmaVersion = ecmaVersionArg ? ecmaVersionArg : config.ecmaVersion | ||
const files = filesArg && filesArg.length ? filesArg : [].concat(config.files) | ||
const esmodule = options.module ? options.module : config.module | ||
const allowHashBang = options.allowHashBang | ||
? options.allowHashBang | ||
: config.allowHashBang | ||
const pathsToIgnore = | ||
options.not | ||
? options.not.split(',') | ||
: [].concat(config.not || []) | ||
const allowHashBang = options.allowHashBang ? options.allowHashBang : config.allowHashBang | ||
const pathsToIgnore = options.not ? options.not.split(',') : [].concat(config.not || []) | ||
if (!expectedEcmaVersion) { | ||
logger.error( | ||
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc' | ||
'No ecmaScript version passed in or found in .escheckrc. Please set your ecmaScript version in the CLI or in .escheckrc', | ||
) | ||
@@ -94,5 +80,3 @@ process.exit(1) | ||
if (!files || !files.length) { | ||
logger.error( | ||
'No files were passed in please pass in a list of files to es-check!' | ||
) | ||
logger.error('No files were passed in please pass in a list of files to es-check!') | ||
process.exit(1) | ||
@@ -158,5 +142,3 @@ } | ||
default: | ||
logger.error( | ||
'Invalid ecmaScript version, please pass a valid version, use --help for help' | ||
) | ||
logger.error('Invalid ecmaScript version, please pass a valid version, use --help for help') | ||
process.exit(1) | ||
@@ -180,6 +162,3 @@ } | ||
const filtered = globbedFiles.filter( | ||
(filePath) => | ||
!expandedPathsToIgnore.some((ignoreValue) => | ||
filePath.includes(ignoreValue) | ||
) | ||
(filePath) => !expandedPathsToIgnore.some((ignoreValue) => filePath.includes(ignoreValue)), | ||
) | ||
@@ -207,5 +186,3 @@ return filtered | ||
if (globbedFiles.length === 0) { | ||
logger.error( | ||
`ES-Check: Did not find any files to check for ${pattern}.` | ||
) | ||
logger.error(`ES-Check: Did not find any files to check for ${pattern}.`) | ||
process.exit(1) | ||
@@ -218,3 +195,2 @@ } | ||
const code = fs.readFileSync(file, 'utf8') | ||
logger.debug(`ES-Check: checking ${file}`) | ||
@@ -224,9 +200,7 @@ try { | ||
} catch (err) { | ||
logger.debug( | ||
`ES-Check: failed to parse file: ${file} \n - error: ${err}` | ||
) | ||
logger.debug(`ES-Check: failed to parse file: ${file} \n - error: ${err}`) | ||
const errorObj = { | ||
err, | ||
stack: err.stack, | ||
file | ||
file, | ||
} | ||
@@ -239,5 +213,3 @@ errArray.push(errorObj) | ||
if (errArray.length > 0) { | ||
logger.error( | ||
`ES-Check: there were ${errArray.length} ES version matching errors.` | ||
) | ||
logger.error(`ES-Check: there were ${errArray.length} ES version matching errors.`) | ||
errArray.forEach((o) => { | ||
@@ -244,0 +216,0 @@ logger.info(` |
{ | ||
"name": "es-check", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Checks the ECMAScript version of .js glob against a specified version of ECMAScript with a shell command", | ||
@@ -14,12 +14,16 @@ "main": "index.js", | ||
"scripts": { | ||
"chore:delete-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi", | ||
"chore:branch": "git checkout -b chore-changelog", | ||
"chore:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", | ||
"chore:pr": "git add . && git commit -m '[chore] updates changelog' --no-verify && git push origin chore-changelog -f", | ||
"chore": "pnpm run chore:delete-branch && pnpm run chore:branch && pnpm run chore:changelog && pnpm run chore:pr", | ||
"commit": "git-cz", | ||
"commit-msg": "commitlint --edit $1", | ||
"husky-setup": "path-exists .husky/commit-msg || (husky install && pnpm husky-setup:commit-msg && pnpm husky-setup:post-merge && pnpm husky-setup:pre-commit)", | ||
"husky-setup:commit-msg": "npx husky add .husky/commit-msg 'pnpm run commit-msg'", | ||
"husky-setup:post-merge": "npx husky add .husky/post-merge 'pnpm run setup'", | ||
"husky-setup:pre-commit": "npx husky add .husky/pre-commit 'pnpm run pre-commit'", | ||
"lint": "eslint index.js --fix", | ||
"lint:ci": "eslint index.js", | ||
"prepush": "pnpm run lint && pnpm test", | ||
"postpublish": "git tag $npm_package_version && git push origin --tags && pnpm run chore", | ||
"pre-commit": "pnpm lint && pnpm test", | ||
"prepare": "is-ci || pnpm husky-setup", | ||
"prepublishOnly": "pnpm test", | ||
"release": "release-it", | ||
"report:coverage": "nyc report --reporter=lcov > coverage.lcov && codecov", | ||
"setup": "pnpm install --reporter=silent", | ||
"test": "nyc mocha test.js --timeout 10s --coverage" | ||
@@ -49,3 +53,5 @@ }, | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.5.1" | ||
"path-exists-cli": "^2.0.0", | ||
"prettier": "^2.5.1", | ||
"release-it": "^15.1.3" | ||
}, | ||
@@ -92,11 +98,7 @@ "dependencies": { | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS", | ||
"post-checkout": "if [[ $HUSKY_GIT_PARAMS =~ 1$ ]]; then pnpm i -r; fi", | ||
"post-merge": "pnpm i -r", | ||
"post-rewrite": "pnpm i -r", | ||
"pre-commit": "pnpm test && pnpm lint" | ||
"release-it": { | ||
"github": { | ||
"release": true | ||
} | ||
} | ||
} |
@@ -42,2 +42,3 @@ <p align="center"> | ||
<a href="/issues">Issues</a> | ||
<a href="#roadmap">Roadmap</a> | ||
</p> | ||
@@ -217,1 +218,12 @@ | ||
- [Brandon Casey](https://github.com/BrandonOCasey) | ||
### Roadmap | ||
- Provide compilation step to support esm | ||
- non-user-facing | ||
- required to keep package dependencies up-to-date as more dependencies are ESM-only | ||
- Provide checks for _theoretical_ keywork words | ||
- Things like `Map` and `Object.assign` are not keywords that fail ECMAScript | ||
compilation depending on specific versions of ECMAScript. However, they hint at additions to ECMAScript that previous version did not support. | ||
- This feature will enhance an already built-in confiration feature to provide more out-of-the-box support for ECMAScript checking. | ||
- If enabled, this feature will warn (or fail) based on _theoretical_ ECMAScript keywords. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18559
228
15
200