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

remark-lint-no-shell-dollars

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-no-shell-dollars - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

index.d.ts

81

index.js

@@ -11,3 +11,4 @@ /**

*
* @example {"name": "ok.md"}
* @example
* {"name": "ok.md"}
*

@@ -37,6 +38,7 @@ * ```bash

* ```js
* $('div').remove();
* $('div').remove()
* ```
*
* @example {"name": "not-ok.md", "label": "input"}
* @example
* {"name": "not-ok.md", "label": "input"}
*

@@ -52,3 +54,4 @@ * ```sh

*
* @example {"name": "not-ok.md", "label": "output"}
* @example
* {"name": "not-ok.md", "label": "output"}
*

@@ -59,16 +62,14 @@ * 1:1-3:4: Do not use dollar signs before shell commands

'use strict'
/**
* @typedef {import('mdast').Root} Root
*/
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var generated = require('unist-util-generated')
import {lintRule} from 'unified-lint-rule'
import {visit} from 'unist-util-visit'
import {generated} from 'unist-util-generated'
module.exports = rule('remark-lint:no-shell-dollars', noShellDollars)
var reason = 'Do not use dollar signs before shell commands'
// List of shell script file extensions (also used as code flags for syntax
// highlighting on GitHub):
// See: <https://github.com/github/linguist/blob/40992ba/lib/linguist/languages.yml#L4984>
var flags = [
const flags = new Set([
'sh',

@@ -84,38 +85,34 @@ 'bash',

'zsh'
]
])
function noShellDollars(tree, file) {
visit(tree, 'code', visitor)
const remarkLintNoShellDollars = lintRule(
'remark-lint:no-shell-dollars',
/** @type {import('unified-lint-rule').Rule<Root, void>} */
(tree, file) => {
visit(tree, 'code', (node) => {
// Check both known shell code and unknown code.
if (!generated(node) && node.lang && flags.has(node.lang)) {
const lines = node.value
.split('\n')
.filter((line) => line.trim().length > 0)
let index = -1
function visitor(node) {
var lines
var line
var length
var index
if (lines.length === 0) {
return
}
// Check both known shell code and unknown code.
if (!generated(node) && node.lang && flags.indexOf(node.lang) !== -1) {
lines = node.value.split('\n').filter(notEmpty)
length = lines.length
index = -1
while (++index < lines.length) {
const line = lines[index]
if (length === 0) {
return
}
if (line.trim() && !/^\s*\$\s*/.test(line)) {
return
}
}
while (++index < length) {
line = lines[index]
if (line.trim() && !line.match(/^\s*\$\s*/)) {
return
}
file.message('Do not use dollar signs before shell commands', node)
}
file.message(reason, node)
}
})
}
)
function notEmpty(line) {
return line.trim().length !== 0
}
}
export default remarkLintNoShellDollars
{
"name": "remark-lint-no-shell-dollars",
"version": "2.0.2",
"version": "3.0.0",
"description": "remark-lint rule to warn when shell code is prefixed by dollars",

@@ -24,11 +24,27 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {
"unified-lint-rule": "^1.0.0",
"unist-util-generated": "^1.1.0",
"unist-util-visit": "^2.0.0"
"@types/mdast": "^3.0.0",
"unified": "^10.0.0",
"unified-lint-rule": "^2.0.0",
"unist-util-generated": "^2.0.0",
"unist-util-visit": "^4.0.0"
},
"xo": false
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage"
},
"xo": false,
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true
}
}

@@ -55,3 +55,3 @@ <!--This file is generated-->

```js
$('div').remove();
$('div').remove()
```

@@ -88,2 +88,5 @@ ````

This package is [ESM only][esm]:
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
[npm][]:

@@ -95,2 +98,5 @@

This package exports no identifiers.
The default export is `remarkLintNoShellDollars`.
## Use

@@ -122,10 +128,13 @@

```diff
var remark = require('remark')
var report = require('vfile-reporter')
import {remark} from 'remark'
import {reporter} from 'vfile-reporter'
import remarkLint from 'remark-lint'
import remarkLintNoShellDollars from 'remark-lint-no-shell-dollars'
remark()
.use(require('remark-lint'))
+ .use(require('remark-lint-no-shell-dollars'))
.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file))
.use(remarkLint)
+ .use(remarkLintNoShellDollars)
.process('_Emphasis_ and **importance**')
.then((file) => {
console.error(reporter(file))
})

@@ -148,5 +157,5 @@ ```

[build-badge]: https://img.shields.io/travis/remarkjs/remark-lint/main.svg
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
[build]: https://travis-ci.org/remarkjs/remark-lint
[build]: https://github.com/remarkjs/remark-lint/actions

@@ -171,6 +180,8 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg

[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://spectrum.chat/unified/remark
[chat]: https://github.com/remarkjs/remark/discussions
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://docs.npmjs.com/cli/install

@@ -177,0 +188,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