Skip to content

Commit e20a366

Browse files
authored
feat!: switch the recommended config to flat (#118)
1 parent 826b71f commit e20a366

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ yarn add --dev eslint-plugin-security
2020

2121
## Usage
2222

23-
Add the following to your `.eslintrc` file:
23+
Add the following to your `eslint.config.js` file:
2424

2525
```js
26-
"extends": [
27-
"plugin:security/recommended"
28-
]
26+
const pluginSecurity = require('eslint-plugin-security');
27+
28+
module.exports = [pluginSecurity.configs.recommended];
2929
```
3030

3131
## Developer guide

index.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
module.exports = {
9+
const plugin = {
1010
meta: {
1111
name: pkg.name,
1212
version: pkg.version,
@@ -43,25 +43,29 @@ module.exports = {
4343
'detect-new-buffer': 0,
4444
'detect-bidi-characters': 0,
4545
},
46-
configs: {
47-
recommended: {
48-
plugins: ['security'],
49-
rules: {
50-
'security/detect-buffer-noassert': 'warn',
51-
'security/detect-child-process': 'warn',
52-
'security/detect-disable-mustache-escape': 'warn',
53-
'security/detect-eval-with-expression': 'warn',
54-
'security/detect-new-buffer': 'warn',
55-
'security/detect-no-csrf-before-method-override': 'warn',
56-
'security/detect-non-literal-fs-filename': 'warn',
57-
'security/detect-non-literal-regexp': 'warn',
58-
'security/detect-non-literal-require': 'warn',
59-
'security/detect-object-injection': 'warn',
60-
'security/detect-possible-timing-attacks': 'warn',
61-
'security/detect-pseudoRandomBytes': 'warn',
62-
'security/detect-unsafe-regex': 'warn',
63-
'security/detect-bidi-characters': 'warn',
64-
},
65-
},
46+
configs: {}, // was assigned later so we can reference `plugin`
47+
};
48+
49+
const recommended = {
50+
plugins: { security: plugin },
51+
rules: {
52+
'security/detect-buffer-noassert': 'warn',
53+
'security/detect-child-process': 'warn',
54+
'security/detect-disable-mustache-escape': 'warn',
55+
'security/detect-eval-with-expression': 'warn',
56+
'security/detect-new-buffer': 'warn',
57+
'security/detect-no-csrf-before-method-override': 'warn',
58+
'security/detect-non-literal-fs-filename': 'warn',
59+
'security/detect-non-literal-regexp': 'warn',
60+
'security/detect-non-literal-require': 'warn',
61+
'security/detect-object-injection': 'warn',
62+
'security/detect-possible-timing-attacks': 'warn',
63+
'security/detect-pseudoRandomBytes': 'warn',
64+
'security/detect-unsafe-regex': 'warn',
65+
'security/detect-bidi-characters': 'warn',
6666
},
6767
};
68+
69+
Object.assign(plugin.configs, { recommended });
70+
71+
module.exports = plugin;

0 commit comments

Comments
 (0)