Skip to content

Commit

Permalink
chore: npm run format (#106)
Browse files Browse the repository at this point in the history
* chore: npm run format

* fix .eslint-doc-generatorrc.js
  • Loading branch information
ota-meshi authored Jan 11, 2023
1 parent 4294d29 commit 65136a3
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { format } = require('prettier');
const { prettier: prettierRC } = require('./.prettierrc.json');
const prettierRC = require('./.prettierrc.json');

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
Expand Down
13 changes: 4 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": [
"eslint:recommended",
"prettier",
"plugin:eslint-plugin/recommended"
],
"extends": ["eslint:recommended", "prettier", "plugin:eslint-plugin/recommended"],
"parserOptions": {
"ecmaVersion": "latest"
},
Expand All @@ -17,11 +13,10 @@
"eslint-plugin/require-meta-docs-url": [
"error",
{
"pattern":
"https://github.com/eslint-community/eslint-plugin-security/blob/main/docs/rules/{{name}}.md",
},
"pattern": "https://github.com/eslint-community/eslint-plugin-security/blob/main/docs/rules/{{name}}.md"
}
],
"eslint-plugin/require-meta-schema": "off", // TODO: enable
"eslint-plugin/require-meta-type": "off"// TODO: enable
"eslint-plugin/require-meta-type": "off" // TODO: enable
}
}
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"line-length": false,
"no-inline-html": { "allowed_elements": ["kbd"]}
"no-inline-html": { "allowed_elements": ["kbd"] }
}
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- 1.5.0
- Fix avoid crash when exec() is passed no arguments
Closes [#82](https://github.com/nodesecurity/eslint-plugin-security/pull/82) with ref as [#23](https://github.com/nodesecurity/eslint-plugin-security/pull/23)
Closes [#82](https://github.com/nodesecurity/eslint-plugin-security/pull/82) with ref as [#23](https://github.com/nodesecurity/eslint-plugin-security/pull/23)
- Fix incorrect method name in detect-buffer-noassert
Closes [#63](https://github.com/nodesecurity/eslint-plugin-security/pull/63) and [#80](https://github.com/nodesecurity/eslint-plugin-security/pull/80)
- Clean up source code formatting
Expand All @@ -17,8 +17,8 @@
- Fix linting errors and step
[Lint errors](https://github.com/nodesecurity/eslint-plugin-security/commit/1258118c2d07722e9fb388a672b287bb43bc73b3), [Lint step](https://github.com/nodesecurity/eslint-plugin-security/commit/84f3ed3ab88427753c7ac047d0bccbe557f28aa5)
- Create workflows
Check commit message on pull requests, Set up ci on main branch
- Update test and lint commands to work cross-platform
Check commit message on pull requests, Set up ci on main branch
- Update test and lint commands to work cross-platform
[Commit](https://github.com/nodesecurity/eslint-plugin-security/commit/d3d8e7a27894aa3f83b560f530eb49750e9ee19a)
- Merge pull request [#47](https://github.com/nodesecurity/eslint-plugin-security/pull/47) from pdehaan/add-docs
Add old liftsecurity blog posts to docs/ folder
Expand Down
12 changes: 6 additions & 6 deletions docs/rules/detect-bidi-characters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ As an example, take the following code where `RLO`, `LRI`, `PDI`, `IRI` are plac
```js
#!/usr/bin/env node

var accessLevel = "user";
var accessLevel = 'user';

if (accessLevel != "userRLO LRI// Check if adminPDI IRI") {
console.log("You are an admin.");
if (accessLevel != 'userRLO LRI// Check if adminPDI IRI') {
console.log('You are an admin.');
}
```

Expand All @@ -29,11 +29,11 @@ The code above, will be rendered by a text editor as follows:
```js
#!/usr/bin/env node

var accessLevel = "user";
var accessLevel = 'user';

if (accessLevel != "user") {
if (accessLevel != 'user') {
// Check if admin
console.log("You are an admin.");
console.log('You are an admin.');
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"changelog": "changelog eslint-plugin-security all > CHANGELOG.md",
"cont-int": "npm test && npm run lint",
"format": "prettier --write **/*.{md,js,yml}",
"format": "prettier --write .",
"lint": "npm-run-all \"lint:*\"",
"lint:docs": "markdownlint \"**/*.md\"",
"lint:eslint-docs": "npm run update:eslint-docs -- --check",
Expand Down
6 changes: 3 additions & 3 deletions test/detect-disable-mustache-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tester.run(ruleName, require(`../rules/${ruleName}`), {
invalid: [
{
code: 'a.escapeMarkup = false',
errors: [{ message: 'Markup escaping disabled.' }]
}
]
errors: [{ message: 'Markup escaping disabled.' }],
},
],
});
8 changes: 4 additions & 4 deletions test/detect-eval-with-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const tester = new RuleTester();
const ruleName = 'detect-eval-with-expression';

tester.run(ruleName, require(`../rules/${ruleName}`), {
valid: [{ code: 'eval(\'alert()\')' }],
valid: [{ code: "eval('alert()')" }],
invalid: [
{
code: 'eval(a);',
errors: [{ message: 'eval with argument of type Identifier' }]
}
]
errors: [{ message: 'eval with argument of type Identifier' }],
},
],
});
8 changes: 4 additions & 4 deletions test/detect-new-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ const ruleName = 'detect-new-buffer';
const invalid = 'var a = new Buffer(c)';

tester.run(ruleName, require(`../rules/${ruleName}`), {
valid: [{ code: 'var a = new Buffer(\'test\')' }],
valid: [{ code: "var a = new Buffer('test')" }],
invalid: [
{
code: invalid,
errors: [{ message: 'Found new Buffer' }]
}
]
errors: [{ message: 'Found new Buffer' }],
},
],
});
6 changes: 3 additions & 3 deletions test/detect-no-csrf-before-method-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tester.run(ruleName, require(`../rules/${ruleName}`), {
invalid: [
{
code: 'express.csrf();express.methodOverride()',
errors: [{ message: 'express.csrf() middleware found before express.methodOverride()' }]
}
]
errors: [{ message: 'express.csrf() middleware found before express.methodOverride()' }],
},
],
});
10 changes: 5 additions & 5 deletions test/detect-non-literal-regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ const RuleTester = require('eslint').RuleTester;
const tester = new RuleTester();

const ruleName = 'detect-non-literal-regexp';
const invalid = 'var a = new RegExp(c, \'i\')';
const invalid = "var a = new RegExp(c, 'i')";

tester.run(ruleName, require(`../rules/${ruleName}`), {
valid: [{ code: 'var a = new RegExp(\'ab+c\', \'i\')' }],
valid: [{ code: "var a = new RegExp('ab+c', 'i')" }],
invalid: [
{
code: invalid,
errors: [{ message: 'Found non-literal argument to RegExp Constructor' }]
}
]
errors: [{ message: 'Found non-literal argument to RegExp Constructor' }],
},
],
});
10 changes: 5 additions & 5 deletions test/detect-non-literal-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const tester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
const ruleName = 'detect-non-literal-require';

tester.run(ruleName, require(`../rules/${ruleName}`), {
valid: [{ code: 'var a = require(\'b\')' }, { code: 'var a = require(`b`)' }],
valid: [{ code: "var a = require('b')" }, { code: 'var a = require(`b`)' }],
invalid: [
{
code: 'var a = require(c)',
errors: [{ message: 'Found non-literal argument in require' }]
errors: [{ message: 'Found non-literal argument in require' }],
},
{
code: 'var a = require(`${c}`)',
errors: [{ message: 'Found non-literal argument in require' }]
}
]
errors: [{ message: 'Found non-literal argument in require' }],
},
],
});
6 changes: 3 additions & 3 deletions test/detect-object-injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tester.run(`${ruleName} (Generic)`, Rule, {
invalid: [
{
code: invalidGeneric,
errors: [{ message: 'Generic Object Injection Sink' }]
}
]
errors: [{ message: 'Generic Object Injection Sink' }],
},
],
});
16 changes: 8 additions & 8 deletions test/detect-possible-timing-attacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const ruleName = 'detect-possible-timing-attacks';
const Rule = require(`../rules/${ruleName}`);

const valid = 'if (age === 5) {}';
const invalidLeft = 'if (password === \'mypass\') {}';
const invalidRigth = 'if (\'mypass\' === password) {}';
const invalidLeft = "if (password === 'mypass') {}";
const invalidRigth = "if ('mypass' === password) {}";

// We only check with one string "password" and operator "==="
// to KISS.
Expand All @@ -18,17 +18,17 @@ tester.run(`${ruleName} (left side)`, Rule, {
invalid: [
{
code: invalidLeft,
errors: [{ message: 'Potential timing attack, left side: true' }]
}
]
errors: [{ message: 'Potential timing attack, left side: true' }],
},
],
});

tester.run(`${ruleName} (right side)`, Rule, {
valid: [{ code: valid }],
invalid: [
{
code: invalidRigth,
errors: [{ message: 'Potential timing attack, right side: true' }]
}
]
errors: [{ message: 'Potential timing attack, right side: true' }],
},
],
});
6 changes: 3 additions & 3 deletions test/detect-pseudoRandomBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tester.run(ruleName, require(`../rules/${ruleName}`), {
invalid: [
{
code: invalid,
errors: [{ message: 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers' }]
}
]
errors: [{ message: 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers' }],
},
],
});
16 changes: 8 additions & 8 deletions test/detect-unsafe-regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ tester.run(ruleName, Rule, {
invalid: [
{
code: '/(x+x+)+y/',
errors: [{ message: 'Unsafe Regular Expression' }]
}
]
errors: [{ message: 'Unsafe Regular Expression' }],
},
],
});

tester.run(`${ruleName} (new RegExp)`, Rule, {
valid: [{ code: 'new RegExp(\'^d+1337d+$\')' }],
valid: [{ code: "new RegExp('^d+1337d+$')" }],
invalid: [
{
code: 'new RegExp(\'x+x+)+y\')',
errors: [{ message: 'Unsafe Regular Expression (new RegExp)' }]
}
]
code: "new RegExp('x+x+)+y')",
errors: [{ message: 'Unsafe Regular Expression (new RegExp)' }],
},
],
});

0 comments on commit 65136a3

Please sign in to comment.