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
1
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 1.0.1 to 1.0.2

58

index.js

@@ -24,2 +24,7 @@ /**

*
* Some empty code:
*
* ```command
* ```
*
* It’s fine to use dollars in non-shell code.

@@ -43,10 +48,12 @@ *

'use strict';
'use strict'
var rule = require('unified-lint-rule');
var visit = require('unist-util-visit');
var generated = require('unist-util-generated');
var rule = require('unified-lint-rule')
var visit = require('unist-util-visit')
var generated = require('unist-util-generated')
module.exports = rule('remark-lint:no-shell-dollars', noShellDollars);
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

@@ -67,29 +74,34 @@ * flags for syntax highlighting on GitHub):

'zsh'
];
]
function noShellDollars(ast, file) {
visit(ast, 'code', visitor);
function noShellDollars(tree, file) {
visit(tree, 'code', visitor)
function visitor(node) {
var language = node.lang;
var value = node.value;
var warn;
var lines
var line
var length
var index
if (!language || generated(node)) {
return;
}
/* Check both known shell-code and unknown code. */
if (flags.indexOf(language) !== -1) {
warn = value.length && value.split('\n').every(check);
if (!generated(node) && node.lang && flags.indexOf(node.lang) !== -1) {
lines = node.value.split('\n')
length = lines.length
index = -1
if (warn) {
file.message('Do not use dollar signs before shell-commands', node);
if (length <= 1) {
return
}
while (++index < length) {
line = lines[index]
if (line.trim() && !line.match(/^\s*\$\s*/)) {
return
}
}
file.message(reason, node)
}
}
function check(line) {
return Boolean(!line.trim() || line.match(/^\s*\$\s*/));
}
}
{
"name": "remark-lint-no-shell-dollars",
"version": "1.0.1",
"version": "1.0.2",
"description": "remark-lint rule to warn when shell code is prefixed by dollars",

@@ -13,4 +13,4 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/remark-lint-no-shell-dollars",
"bugs": "https://github.com/wooorm/remark-lint/issues",
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/remark-lint-no-shell-dollars",
"bugs": "https://github.com/remarkjs/remark-lint/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

@@ -17,0 +17,0 @@ "contributors": [

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

| ------ | ------- |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/wooorm/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | |
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | |

@@ -25,18 +25,23 @@ ## Example

````markdown
```sh
echo a
echo a > file
```
```sh
echo a
echo a > file
```
```zsh
$ echo a
a
$ echo a > file
```
```zsh
$ echo a
a
$ echo a > file
```
It’s fine to use dollars in non-shell code.
Some empty code:
```js
$('div').remove();
```
```command
```
It’s fine to use dollars in non-shell code.
```js
$('div').remove();
```
````

@@ -53,6 +58,6 @@

````markdown
```bash
$ echo a
$ echo a > file
```
```bash
$ echo a
$ echo a > file
```
````

@@ -111,2 +116,2 @@

[MIT](https://github.com/wooorm/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT](https://github.com/remarkjs/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)
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