Skip to content

Commit

Permalink
Upgrade to ESLint 9
Browse files Browse the repository at this point in the history
Closes #65.
  • Loading branch information
niksy committed Nov 16, 2024
1 parent ed90592 commit 8363ae5
Show file tree
Hide file tree
Showing 13 changed files with 575 additions and 561 deletions.
36 changes: 0 additions & 36 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node-version:
- 16
- 18
steps:
- name: Clone repository
uses: actions/checkout@v2
Expand Down
84 changes: 41 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
## Install

```sh
npm install eslint@8 eslint-config-nitpick --save-dev
npm install eslint@9 eslint-config-nitpick --save-dev
```

## Usage

Add this config to your `.eslintrc`:
Add this config to your `eslint.config.js`:

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick"
]
}
```js
import configNitpick from 'eslint-config-nitpick';

export default [
configNitpick
];
```

<!-- prettier-ignore-end -->
Expand All @@ -31,34 +31,34 @@ preset:**

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick",
"eslint-config-nitpick/other-preset"
]
}
```js
import configNitpick from 'eslint-config-nitpick';
import configPreset from 'eslint-config-nitpick/other-preset';

export default [
configNitpick,
configPreset
];
```

<!-- prettier-ignore-end -->

## Presets

In addition to default preset, there are also specific presets. You can apply
multiple presets with [ESLint `extends` option][eslint-extends].
In addition to default preset, there are also specific presets.

### Browser

Browser specific rules.

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick/browser"
]
}
```js
import configBrowser from 'eslint-config-nitpick/browser';

export default [
configBrowser
];
```

<!-- prettier-ignore-end -->
Expand All @@ -69,12 +69,12 @@ Rules for testing frameworks (e.g. Mocha).

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick/tests"
]
}
```js
import configTest from 'eslint-config-nitpick/tests';

export default [
configTest
];
```

<!-- prettier-ignore-end -->
Expand All @@ -85,12 +85,12 @@ Vue specific rules.

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick/vue"
]
}
```js
import configVue from 'eslint-config-nitpick/vue';

export default [
...configVue
];
```

<!-- prettier-ignore-end -->
Expand All @@ -101,12 +101,12 @@ TypeScript specific rules.

<!-- prettier-ignore-start -->

```json
{
"extends": [
"eslint-config-nitpick/typescript"
]
}
```js
import configTypescript from 'eslint-config-nitpick/typescript';

export default [
configTypescript
];
```

<!-- prettier-ignore-end -->
Expand All @@ -120,7 +120,5 @@ MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://github.com/niksy/eslint-config-nitpick/actions?query=workflow%3ACI
[ci-img]: https://github.com/niksy/eslint-config-nitpick/workflows/CI/badge.svg?branch=master
[eslint]: http://eslint.org/
[eslint-extends]: http://eslint.org/docs/user-guide/configuring#extending-configuration-files
[tc39-proposals]: https://github.com/tc39/proposals#active-proposals

<!-- prettier-ignore-end -->
16 changes: 10 additions & 6 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
'use strict';
import globals from 'globals';
import pluginUnicorn from 'eslint-plugin-unicorn';

module.exports = {
env: {
node: false,
browser: true
export default {
languageOptions: {
globals: {
...globals.browser
}
},
plugins: {
unicorn: pluginUnicorn
},
plugins: ['eslint-plugin-unicorn'],
rules: {
'no-console': 2,
'no-implicit-globals': 2,
Expand Down
59 changes: 59 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import configPrettier from 'eslint-config-prettier';
import pluginPrettier from 'eslint-plugin-prettier';
import pluginUnicorn from 'eslint-plugin-unicorn';
import pluginImport from 'eslint-plugin-import';
import configTest from './tests.js';
import configBase from './index.js';

export default [
configBase,
configPrettier,
{
plugins: {
prettier: pluginPrettier,
unicorn: pluginUnicorn,
import: pluginImport
},
'rules': {
'prettier/prettier': 1,
'unicorn/prefer-module': 0,
'import/no-commonjs': 0
}
},
{
'files': ['*.js'],
plugins: {
unicorn: pluginUnicorn
},
'rules': {
'unicorn/prevent-abbreviations': [
1,
{
'allowList': {
'env': true,
'props': true,
'prev': true,
'ignoreRefs': true
}
}
]
}
},
{
...configTest,
'files': ['test/**'],
plugins: {
...configTest.plugins,
unicorn: pluginUnicorn,
import: pluginImport
},
'rules': {
...configTest.rules,
'unicorn/prefer-module': 2,
'import/no-commonjs': 2
}
},
{
ignores: ['**/test/fixtures/*.config.*']
}
];
37 changes: 20 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
'use strict';
import globals from 'globals';
import pluginPromise from 'eslint-plugin-promise';
import pluginNode from 'eslint-plugin-n';
import pluginUnicorn from 'eslint-plugin-unicorn';
import pluginJsdoc from 'eslint-plugin-jsdoc';
import pluginImport from 'eslint-plugin-import';

module.exports = {
env: {
node: true,
es2022: true
},
parserOptions: {
export default {
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module'
sourceType: 'module',
globals: {
...globals.node,
...globals.es2022
}
},
plugins: {
promise: pluginPromise,
n: pluginNode,
unicorn: pluginUnicorn,
jsdoc: pluginJsdoc,
import: pluginImport
},
plugins: [
'eslint-plugin-promise',
'eslint-plugin-n',
'eslint-plugin-unicorn',
'eslint-plugin-jsdoc',
'eslint-plugin-import'
],
rules: {
'n/no-sync': 1,
'n/no-restricted-require': 0,
Expand Down Expand Up @@ -267,7 +272,6 @@ module.exports = {
'no-unexpected-multiline': 2,
'no-unreachable': 2,
'use-isnan': 2,
'valid-jsdoc': 0,
'valid-typeof': 2,
'no-unsafe-finally': 1,
'no-unsafe-negation': 2,
Expand Down Expand Up @@ -445,7 +449,6 @@ module.exports = {
}
],
'operator-assignment': 0,
'require-jsdoc': 0,
'sort-keys': 0,
'sort-vars': 0,
'line-comment-position': 0,
Expand Down
43 changes: 26 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"license": "MIT",
"author": "Ivan Nikolić <[email protected]> (http://ivannikolic.com)",
"main": "index.js",
"type": "module",
"exports": {
".": "./index.js",
"./browser": "./browser.js",
"./tests": "./tests.js",
"./vue": "./vue.js",
"./typescript": "./typescript.js"
},
"directories": {
"test": "test"
},
Expand All @@ -16,35 +24,36 @@
"scripts": {
"lint": "eslint '{index,browser,tests,vue,typescript,test/index}.js'",
"release": "np --no-release-draft",
"test": "npm run lint && eslint-find-rules -u ./test/fixtures/all-rules.cjs && mocha 'test/index.js'",
"test": "npm run lint && mocha 'test/index.js'",
"test:watch": "npm test -- --watch",
"version": "if [ $(git rev-parse --abbrev-ref HEAD) == 'master' ]; then sed -i '' '/\\[unreleased\\]:/d' CHANGELOG.md && version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md; else echo; fi",
"postpublish": "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN github-release-from-changelog",
"prerelease": "npm run lint"
},
"dependencies": {
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^48.2.2",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-n": "^17.2.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-vue": "^9.7.0",
"resolve-from": "^5.0.0"
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-mocha": "^10.5.0",
"eslint-plugin-n": "^17.13.2",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-unicorn": "^56.0.0",
"eslint-plugin-vue": "^9.31.0",
"globals": "^15.12.0",
"resolve-from": "^5.0.0",
"vue-eslint-parser": "^9.4.3"
},
"devDependencies": {
"changelog-verify": "^1.1.2",
"eslint": "^8.57.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-find-rules": "^4.0.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.1",
"github-release-from-changelog": "^2.1.1",
"husky": "^4.3.0",
"husky": "^4.3.8",
"lint-staged": "^10.4.2",
"lodash": "^4.17.10",
"mocha": "^10.4.0",
"np": "^7.6.0",
"prettier": "^3.2.5",
"lodash": "^4.17.21",
"mocha": "^10.8.2",
"np": "^7.7.0",
"prettier": "^3.3.3",
"version-changelog": "^3.1.1"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit 8363ae5

Please sign in to comment.