Skip to content

Commit

Permalink
feat(index.js): use flat config
Browse files Browse the repository at this point in the history
Closes #136
  • Loading branch information
dustinspecker committed May 22, 2024
1 parent e104c28 commit 5716bf7
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 44 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

5 changes: 0 additions & 5 deletions .eslintrc.json

This file was deleted.

18 changes: 18 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const eslintJS = require('@eslint/js')
const eslintPluginEslintPlugin = require('eslint-plugin-eslint-plugin')
const eslintPluginNoUseExtendNative = require('.')
const globals = require('globals')

module.exports = [
eslintJS.configs.recommended,
eslintPluginEslintPlugin.configs['flat/recommended'],
eslintPluginNoUseExtendNative.configs.recommended,
{
languageOptions: {
globals: globals.node,
},
ignores: [
"coverage",
],
}
]
29 changes: 20 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
/* eslint no-var: 0 */
'use strict'
var rule = require('./src/no-use-extend-native')
const rule = require('./src/no-use-extend-native')
const {name, version} = require('./package.json')

module.exports = {
const plugin = {
meta: {
name,
version
},
rules: {
'no-use-extend-native': rule
},
configs: {
recommended: {
plugins: ['no-use-extend-native'],
rules: {
'no-use-extend-native/no-use-extend-native': 2
}
configs: {},
}

Object.assign(plugin.configs, {
recommended: {
plugins: {
'no-use-extend-native': plugin
},
rules: {
'no-use-extend-native/no-use-extend-native': 2
}
}
}
})

module.exports = plugin
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@
"is-proto-prop": "^2.0.0"
},
"devDependencies": {
"@eslint/js": "^9.3.0",
"ava": "^6.1.3",
"c8": "^9.1.0",
"coveralls": "^3.1.0",
"eslint-ava-rule-tester": "^5.0.1",
"eslint-config-dustinspecker": "^5.0.0",
"eslint-path-formatter": "^0.1.1",
"eslint-plugin-new-with-error": "^5.0.0"
"eslint-plugin-eslint-plugin": "^6.1.0",
"eslint-plugin-new-with-error": "^5.0.0",
"globals": "^15.3.0"
},
"peerDependencies": {
"eslint": "^8.57.0"
"eslint": "^9.3.0"
},
"c8": {
"reporter": [
Expand Down
37 changes: 15 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,30 @@ npm install --save-dev eslint-plugin-no-use-extend-native
```

## Usage
In your `.eslintrc` file add the plugin as such:
In your `eslint.config.js` file add the plugin as such:

```javascript
{
plugins: [
'no-use-extend-native'
]
}
```
const eslintPluginNoUseExtendNative = require('eslint-plugin-no-use-extend-native')

To modify the single rule, `no-use-extend-native`, add the rule to your `.eslintrc.*` as such:
```javascript
{
plugins: [
'no-use-extend-native'
],
module.exports = [
plugins: {
'no-use-extend-native': eslintPluginNoUseExtendNative,
},
rules: {
'no-use-extend-native/no-use-extend-native': 1
}
}
'no-use-extend-native/no-use-extend-native': 2,
},
]
```

The default value is `2`.

If you want the default, you can also just use the following instead of
If you want the default of the single rule being enabled as an error, you can also just use the following instead of
all of the above:

```javascript
{
extends: ['plugin:no-use-extend-native/recommended']
}
const eslintPluginNoUseExtendNative = require('eslint-plugin-no-use-extend-native')

module.exports = [
eslintPluginNoUseExtendNative.configs.recommended,
]
```

With this plugin enabled, ESLint will find issues with using extended native objects:
Expand Down

0 comments on commit 5716bf7

Please sign in to comment.