Skip to content

Commit

Permalink
Release 1.1.2 (#30)
Browse files Browse the repository at this point in the history
- chore: update to eslint 8 standards
- publish as @haraka/eslint-config
- include Haraka globals
- doc(README): update
- add root:true and envs
- add lint & prettier scripts
- removed rules/no-newline-no-curly-if
  • Loading branch information
msimerson committed Apr 7, 2024
1 parent cb38314 commit b2ce798
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ checks:
threshold: 10

ratings:
paths:
- "**.js"
paths:
- "**.js"
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ env:
es6: true
es2020: true

extends: [ "eslint:recommended" ]
extends: ["eslint:recommended"]
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: CI

on: [ push, pull_request ]
on: [push, pull_request]

env:
CI: true

jobs:

lint:
uses: haraka/.github/.github/workflows/lint.yml@master

test:
needs: [ lint ]
needs: [lint]
uses: haraka/.github/.github/workflows/ubuntu.yml@master

windows:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: ["master"]
pull_request:
branches: [ "master" ]
branches: ["master"]
schedule:
- cron: "56 17 * * 1"

Expand All @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ javascript ]
language: [javascript]

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ env:
jobs:
publish:
uses: haraka/.github/.github/workflows/publish.yml@master
secrets: inherit
secrets: inherit
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

#### [1.1.2] - 2024-04-06

- remove rule no-newline-no-curly-if
- remove haraka:recommended
- remove rules included in eslint:recommended

#### 1.1.0 - 2024-04-06

- chore: update to eslint 8 standards
- publish as @haraka/eslint-config
- add lint & prettier scripts
- add Haraka globals, root:true, and envs
- doc(README): update

#### [1.0.16] - 2024-04-05

- chore: remove eslint deprecated formatting rules
Expand Down Expand Up @@ -64,7 +78,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
#### 1.0.5 - 2017-02-01

- fixed missing comma at end of no-empty rule
- added "no-undef": 1 (warnings only)
- added "no-undef": 1 (warnings only)

#### 1.0.3 - 2017-01-27

Expand All @@ -75,7 +89,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
- added env:es6=true
- added space-before-function-paren rule


[1.0.11]: https://github.com/haraka/haraka-eslint/releases/tag/1.0.11
[1.0.15]: https://github.com/haraka/haraka-eslint/releases/tag/1.0.15
[1.0.16]: https://github.com/haraka/haraka-eslint/releases/tag/v1.0.16
[1.1.2]: https://github.com/haraka/haraka-eslint/releases/tag/v1.1.2
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@

## Install

In your Haraka plugin:
In your Haraka module:

1. Add to NPM dependencies:
`npm install --save-dev eslint eslint-plugin-haraka`

2. Install an eslint config file:
`npm install --save-dev @haraka/eslint-config`

2. Configure eslint:

```sh
tee .eslintrc.yaml <<EOLINT
plugins: [ haraka ]
extends: [ eslint:recommended, plugin:haraka/recommended ]
EOLINT
echo 'extends: "@haraka"' > .eslintrc.yaml
```

3. Add within the "scripts" section of `package.json`:
3. Add to the "scripts" section of `package.json`:

```json
"lint": "npx eslint *.js test"
"lintfix": "npx eslint --fix *.js test"
"lint": "npx eslint@8 *.js test"
"lint:fix": "npx eslint@8 --fix *.js test"
```

4. Within your CI workflow:
Expand All @@ -40,15 +38,15 @@ To check your project against lint rules:

Step #4 above does this automatically when CI tests are set up.

If you agree with the lint suggestions, you can run `npm run lintfix` and the changes will be made to your files automatically.

If you disagree, you can add custom rules to your .eslintrc file.
If you agree with the lint suggestions, you can run `npm run lint:fix` and the changes will be made to your files automatically.

Custom rules can be added to the .eslintrc file.

<!-- leave these buried at the bottom of the document -->

[ci-img]: https://github.com/haraka/haraka-eslint/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/haraka/haraka-eslint/actions/workflows/ci.yml
[clim-img]: https://codeclimate.com/github/haraka/haraka-eslint/badges/gpa.svg
[clim-url]: https://codeclimate.com/github/haraka/haraka-eslint
[npm-img]: https://nodei.co/npm/eslint-plugin-haraka.png
[npm-url]: https://www.npmjs.com/package/eslint-plugin-haraka
[npm-img]: https://nodei.co/npm/@haraka/eslint-config.png
[npm-url]: https://www.npmjs.com/package/@haraka/eslint-config
61 changes: 23 additions & 38 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
'use strict';
"use strict";

// 0 = off
// 1 = warn
// 2 = error

const recommendedRules = {
"dot-notation": "error",
"one-var": ["error", "never"],
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-shadow": "error",
module.exports = {
env: {
node: true,
es6: true,
mocha: true,
},
root: true,
extends: "eslint:recommended",
globals: {
OK: true,
CONT: true,
DENY: true,
DENYSOFT: true,
DENYDISCONNECT: true,
DENYSOFTDISCONNECT: true,
},
rules: {
// 0 = off // 1 = warn // 2 = error
"no-empty": ["error", { allowEmptyCatch: true }],
"no-undef": "warn",
"no-unused-vars": [ "warn", { "args": "none" }],
"no-console": "off",
"no-path-concat": "error",
"no-cond-assign": ["error", "except-parens"],
"no-constant-condition": ["error", { "checkLoops": false }],
"prefer-const": ["error", {"ignoreReadBeforeAssign": true}],
"no-var": "error",
"object-shorthand": ["warn", "always"],
"prefer-template": "warn"
};

// This is here so we know how this "rules" section is used in the future
// - You can enable this rule by adding: `"haraka/no-newline-no-curly-if": 2` to your module's list of rules.
// The rule prevents: `if (bool)\n do_thing()` and forces if()s with no curly to be on a single line.
const rules = {
"no-newline-no-curly-if": require('./rules/no-newline-no-curly-if'),
"no-constant-condition": ["error", { checkLoops: false }],
"prefer-const": ["error", { ignoreReadBeforeAssign: true }],
},
};

module.exports = {
rules: rules,
configs: {
recommended: {
"env": {
"node": true,
"es6": true
},
rules: recommendedRules,
}
}
}
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"name": "eslint-plugin-haraka",
"version": "1.0.16",
"description": "eslint rules for Haraka projects",
"name": "@haraka/eslint-config",
"version": "1.1.2",
"description": "eslint config for Haraka projects",
"keywords": [
"eslint",
"eslintconfig"
],
"main": "index.js",
"files": [
"CHANGELOG.md", "rules"
"CHANGELOG.md",
"rules"
],
"scripts": {
"lint": "npx eslint@^8 *.js",
"format": "npm run prettier:fix && npm run lint:fix",
"lint": "npx eslint@8 *.js **/*.js",
"lint:fix": "npm run lint -- --fix",
"prettier": "npx prettier . --check",
"prettier:fix": "npx prettier . --write",
"test": "node index.js"
},
"repository": {
Expand All @@ -26,5 +35,8 @@
"url": "https://github.com/haraka/haraka-eslint/issues"
},
"homepage": "https://github.com/haraka/haraka-eslint#readme",
"devDependencies": { }
"devDependencies": {},
"peerDependencies": {
"eslint": "^8.0.0"
}
}
32 changes: 0 additions & 32 deletions rules/no-newline-no-curly-if.js

This file was deleted.

0 comments on commit b2ce798

Please sign in to comment.