Skip to content

Commit

Permalink
feat: switch the recommended config to flat
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Oct 16, 2023
1 parent 826b71f commit bd3a970
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ yarn add --dev eslint-plugin-security

## Usage

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

```js
"extends": [
"plugin:security/recommended"
]
const pluginSecurity = require('eslint-plugin-security');

module.exports = [pluginSecurity.configs.recommended];
```

## Developer guide
Expand Down
47 changes: 26 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

const pkg = require('./package.json');

module.exports = {
const plugin = {
meta: {
name: pkg.name,
version: pkg.version,
Expand Down Expand Up @@ -43,25 +43,30 @@ module.exports = {
'detect-new-buffer': 0,
'detect-bidi-characters': 0,
},
configs: {
recommended: {
plugins: ['security'],
rules: {
'security/detect-buffer-noassert': 'warn',
'security/detect-child-process': 'warn',
'security/detect-disable-mustache-escape': 'warn',
'security/detect-eval-with-expression': 'warn',
'security/detect-new-buffer': 'warn',
'security/detect-no-csrf-before-method-override': 'warn',
'security/detect-non-literal-fs-filename': 'warn',
'security/detect-non-literal-regexp': 'warn',
'security/detect-non-literal-require': 'warn',
'security/detect-object-injection': 'warn',
'security/detect-possible-timing-attacks': 'warn',
'security/detect-pseudoRandomBytes': 'warn',
'security/detect-unsafe-regex': 'warn',
'security/detect-bidi-characters': 'warn',
},
},
configs: {},
};

const recommended = {
plugins: { security: plugin },
rules: {
'security/detect-buffer-noassert': 'warn',
'security/detect-child-process': 'warn',
'security/detect-disable-mustache-escape': 'warn',
'security/detect-eval-with-expression': 'warn',
'security/detect-new-buffer': 'warn',
'security/detect-no-csrf-before-method-override': 'warn',
'security/detect-non-literal-fs-filename': 'warn',
'security/detect-non-literal-regexp': 'warn',
'security/detect-non-literal-require': 'warn',
'security/detect-object-injection': 'warn',
'security/detect-possible-timing-attacks': 'warn',
'security/detect-pseudoRandomBytes': 'warn',
'security/detect-unsafe-regex': 'warn',
'security/detect-bidi-characters': 'warn',
},
};

// assign configs here so we can reference `plugin`
Object.assign(plugin.configs, { recommended });

module.exports = plugin;

0 comments on commit bd3a970

Please sign in to comment.