Skip to content

Commit

Permalink
Merge pull request #33 from dusk-network/feature-12
Browse files Browse the repository at this point in the history
Add eslint-plugin-import-newlines
  • Loading branch information
kieranhall authored Mar 6, 2024
2 parents c225c72 + cb05ac1 commit cd68a31
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ npm i -D @dusk-network/eslint-config

The package requires the following peer dependencies:

- [`eslint`](https://github.com/eslint/eslint) `>=8`
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) `>=2`
- [`eslint`](https://github.com/eslint/eslint) `>=8.57.0`
- [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) `>=9.1.0`
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import) `>=2.29.1`
- [`eslint-plugin-import-newlines`](https://github.com/SeinopSys/eslint-plugin-import-newlines) `>=1.3.4`

If you are using Svelte rules the package need the following optional dependency:
If you are using Svelte rules the package needs the following optional dependency:

- [`eslint-plugin-svelte`](https://github.com/sveltejs/eslint-plugin-svelte) `>=2`
- [`eslint-plugin-svelte`](https://github.com/sveltejs/eslint-plugin-svelte) `>=2.35.1`

## Usage

Add the rulesets you want in the `extends` section of your ESLint configuration file.

e.g. to use both JS and Svelte's rules:
e.g. to use both JS and Svelte rules:

```javascript
// ...
Expand All @@ -36,9 +38,11 @@ extends: [

# npm scripts

- `npm run bump` updates version number using an interactive shell
- `npm run check` checks for deprecated rules and performs the linting check
- `npm run check-js` checks for deprecated JS rules
- `npm run check-rules` checks for deprecated JS and Svelte rules
- `npm run check-svelte` checks for deprecated Svelte rules
- `npm run format` performs the Prettier formatting check
- `npm run format:fix` reformats according to the Prettier rules
- `npm run lint` performs the linting check
- `npm run lint:fix` fixes fixable linting errors
5 changes: 5 additions & 0 deletions js/import-newlines.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
"import-newlines/enforce": "error",
},
};
5 changes: 4 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const rules = ["./base", "./import", "./style"].map(require.resolve);
const rules = ["./base", "./import", "./import-newlines", "./style"].map(
require.resolve
);

module.exports = {
extends: [
Expand All @@ -12,5 +14,6 @@ module.exports = {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["import-newlines"],
rules: {},
};
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "https://dusk.network/",
"mail": "info@dusk.network"
},
"bugs": "https://github.com/dusk-network/dusk-eslint-config/issues/",
"bugs": "https://github.com/dusk-network/eslint-config/issues/",
"contributors": [
"Andrea Scartabelli <andrea.scartabelli@gmail.com>",
"Kieran Hall <kieran@dusk.network>"
Expand All @@ -17,7 +17,7 @@
"js/**/*.js",
"svelte/**/*.js"
],
"homepage": "https://github.com/dusk-network/dusk-eslint-config/",
"homepage": "https://github.com/dusk-network/eslint-config/",
"keywords": [
"dusk",
"dusk network",
Expand All @@ -28,33 +28,37 @@
"name": "@dusk-network/eslint-config",
"repository": {
"type": "git",
"url": "https://github.com/dusk-network/dusk-eslint-config.git"
"url": "https://github.com/dusk-network/eslint-config.git"
},
"scripts": {
"check": "npm run check-rules && npm run check-format && npm run lint",
"check-format": "prettier . --check",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"check-js": "eslint-find-rules -nd js/index.js && eslint-config-prettier js/index.js",
"check-rules": "npm run check-js && npm run check-svelte",
"check-svelte": "eslint-find-rules -nd svelte/index.js && eslint-config-prettier svelte/index.js",
"lint": "eslint ."
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"version": "3.1.0",
"devDependencies": {
"@dusk-network/prettier-config": "1.0.0",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-find-rules": "4.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-import-newlines": "1.3.4",
"eslint-plugin-svelte": "2.35.1",
"prettier": "3.2.5",
"svelte": "4.2.10"
"svelte": "4.2.12"
},
"optionalDependencies": {
"eslint-plugin-svelte": ">=2.35.1"
},
"peerDependencies": {
"eslint": ">=8.56.0",
"eslint": ">=8.57.0",
"eslint-config-prettier": ">=9.1.0",
"eslint-plugin-import": ">=2.29.1"
"eslint-plugin-import": ">=2.29.1",
"eslint-plugin-import-newlines": ">=1.3.4"
}
}

0 comments on commit cd68a31

Please sign in to comment.