Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

common-lint

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-lint - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

57

index.js
#!/usr/bin/env node
const findPackageJson = require('find-package-json')
const childProcess = require('child_process')
const args = process.argv.slice(2)
const startLocation = args.reduce((acc, cur) => {
const startsWithDash = cur.startsWith('-')
if (startsWithDash === false) {
acc = cur
}
return acc
}, process.cwd())
// It's important that we start looking in the process CWD.
// We don't use `__dirname` here because it's the path to this file.
const startLocation = process.cwd()
const finder = findPackageJson(startLocation)

@@ -12,13 +23,39 @@

const packageFile = finder.next()
const { dependencies, devDependencies } = packageFile.value
const hasPackageFile = packageFile.value != null
const allDependencies = [dependencies, devDependencies]
const hasStandard = allDependencies.some((deps = {}) =>
Object.keys(deps).includes('standard')
)
let command = 'eslint'
if (hasStandard) {
require('standard/bin/cmd')
} else {
require('eslint/bin/eslint')
if (hasPackageFile) {
const { dependencies, devDependencies } = packageFile.value
const allDependencies = [dependencies, devDependencies]
const hasStandard = allDependencies.some((deps = {}) =>
Object.keys(deps).includes('standard')
)
if (hasStandard) {
command = 'standard'
}
}
const notFoundError = `
Could not locate "${command}", is it installed?
- npm -g install ${command}
- yarn global add ${command}
Please ensure that "${command} --help" works and then try again.
`
try {
childProcess.execFileSync(command, args, {
stdio: 'inherit'
})
} catch (err) {
// We can safely ignore most errors, but we *do* want to catch "not found"
// errors and output them to the user.
if (err.code === 'ENOENT') {
console.error(notFoundError)
process.exit(127)
}
}

20

package.json
{
"name": "common-lint",
"version": "1.0.2",
"version": "2.0.0",
"description": "compatibility for both standard and eslint",

@@ -11,13 +11,19 @@ "main": "index.js",

"dependencies": {
"eslint": "^6.4.0",
"find-package-json": "^1.2.0",
"standard": "^14.3.1"
"find-package-json": "^1.2.0"
},
"peerDependencies": {
"eslint": "*",
"standard": "*"
},
"bin": {
"common-lint": "index.js",
"clint": "index.js"
"common-lint": "./index.js",
"clint": "./index.js"
},
"scripts": {
"test": "index.js"
"test": "./index.js"
},
"devDependencies": {
"eslint": "^6.4.0",
"standard": "^14.3.1"
}
}

@@ -5,4 +5,2 @@ # common-lint

## Usage

@@ -41,3 +39,3 @@

```shell
npm -g install common-readme
npm -g install common-lint
```

@@ -48,3 +46,3 @@

```shell
yarn global add common-readme
yarn global add common-lint
```

@@ -51,0 +49,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc