Skip to content

Commit

Permalink
feat: add config recommended-legacy
Browse files Browse the repository at this point in the history
it also moves rule tests to `./test/rules`, and adds a test for the configs.

fixes #131

Signed-off-by: 唯然 <weiran.zsd@outlook.com>
  • Loading branch information
aladdin-add committed Dec 14, 2023
1 parent 27cd160 commit dac80c9
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ yarn add --dev eslint-plugin-security

## Usage

### flat config(requires eslint >= v8.23.0)

Add the following to your `eslint.config.js` file:

```js
Expand All @@ -28,6 +30,16 @@ const pluginSecurity = require('eslint-plugin-security');
module.exports = [pluginSecurity.configs.recommended];
```

### eslintrc config(legacy)

Add the following to your `.eslintrc` file:

```js
"extends": [
"plugin:security/recommended-legacy"
]
```

## Developer guide

- Use [GitHub pull requests](https://help.github.com/articles/using-pull-requests).
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const recommended = {
},
};

Object.assign(plugin.configs, { recommended });
const recommendedLegacy = {
plugins: ['security'],
rules: recommended.rules,
};

Object.assign(plugin.configs, { recommended, 'recommended-legacy': recommendedLegacy });

module.exports = plugin;
16 changes: 16 additions & 0 deletions test/configs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';
const plugin = require('../../index.js');
const assert = require('assert').strict;

describe('export plugin object', () => {
it('should export rules', () => {
assert(plugin.rules);
assert(typeof plugin.rules['detect-unsafe-regex'] === 'object');
});

it('should export configs', () => {
assert(plugin.configs);
assert(plugin.configs['recommended']);
assert(plugin.configs['recommended-legacy']);
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit dac80c9

Please sign in to comment.