@haraka/eslint-config 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,88 @@
1
+ # Changelog
2
+
3
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
4
+
5
+ ### Unreleased
6
+
7
+ #### [1.1.0] - 2024-04-06
8
+
9
+ - chore: update to eslint 8 standards
10
+ - publish as @haraka/eslint-config
11
+ - add lint & prettier scripts
12
+ - add Haraka globals, root:true, and envs
13
+ - doc(README): update
14
+
15
+ #### [1.0.16] - 2024-04-05
16
+
17
+ - chore: remove eslint deprecated formatting rules
18
+ - see https://eslint.org/blog/2023/10/deprecating-formatting-rules/
19
+ - chore: remove .npmignore, populate [files] in package.json
20
+ - chore: add CodeQL workflow for GitHub code scanning (#27)
21
+ - ci: update to use shared workflows
22
+ - doc(README): fix badge URL, update usage
23
+
24
+ #### [1.0.15] - 2022-05-28
25
+
26
+ - style: replace integers with off|warn|error
27
+ - chore(ci): update configs
28
+ - chore(pkg): add .release submodule
29
+
30
+ #### 1.0.14 - 2021-02-03
31
+
32
+ - CI travis -> Github Actions
33
+ - dep eslint >= 7 (was 6)
34
+ - ecmaVersion 2017 -> 2018
35
+
36
+ #### 1.0.13 - 2019-11-22
37
+
38
+ - eslint prefers 'warn' to 'warning'
39
+
40
+ #### 1.0.12 - 2019-11-22
41
+
42
+ - add prefer-template rule
43
+ - add eslint parserOptions: ecmaVersion: 2017
44
+ - convert .eslintrc.json to .eslintrc.yaml
45
+
46
+ #### [1.0.11] - 2019-07-09
47
+
48
+ - add brace-style rule
49
+
50
+ #### 1.0.10 - 2019-06-22
51
+
52
+ - remove node 6 testing
53
+
54
+ #### 1.0.9 - 2017-09-16
55
+
56
+ - remove no-useless-escape rule
57
+
58
+ #### 1.0.8 - 2017-09-13
59
+
60
+ - import rules from haraka/Haraka
61
+
62
+ #### 1.0.7 - 2017-06-16
63
+
64
+ - Fixes the format of an eslint plugin. The "rules" section is for custom
65
+ rules (i.e. the code for defining the rules), not for enforced rules.
66
+
67
+ #### 1.0.6 - 2017-06-15
68
+
69
+ - eslint 4 enables no-useless-escape. Reduces error to warning until that rule
70
+ is less brain damaged.
71
+
72
+ #### 1.0.5 - 2017-02-01
73
+
74
+ - fixed missing comma at end of no-empty rule
75
+ - added "no-undef": 1 (warnings only)
76
+
77
+ #### 1.0.3 - 2017-01-27
78
+
79
+ - Updated rules from Haraka main repo
80
+ - renamed .eslintrc to .eslintrc.json
81
+ - added travis testing
82
+ - added install and usage sections to README
83
+ - added env:es6=true
84
+ - added space-before-function-paren rule
85
+
86
+ [1.0.11]: https://github.com/haraka/haraka-eslint/releases/tag/1.0.11
87
+ [1.0.15]: https://github.com/haraka/haraka-eslint/releases/tag/1.0.15
88
+ [1.0.16]: https://github.com/haraka/haraka-eslint/releases/tag/v1.0.16
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Haraka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # haraka-eslint
2
+
3
+ [![Build Status][ci-img]][ci-url]
4
+ [![Code Climate][clim-img]][clim-url]
5
+
6
+ [![NPM][npm-img]][npm-url]
7
+
8
+ ## Install
9
+
10
+ In your Haraka plugin:
11
+
12
+ 1. Install an eslint config file:
13
+
14
+ ```sh
15
+ tee .eslintrc.yaml <<EOLINT
16
+ extends: [ @haraka ]
17
+ EOLINT
18
+ ```
19
+
20
+ 2. Add to the "scripts" section of `package.json`:
21
+
22
+ ```json
23
+ "lint": "npx eslint@8 *.js test"
24
+ "lint:fix": "npx eslint@8 --fix *.js test"
25
+ ```
26
+
27
+ 3. Within your CI workflow:
28
+
29
+ `npm run lint`
30
+
31
+ ## Usage
32
+
33
+ To check your project against lint rules:
34
+
35
+ `npm run lint`
36
+
37
+ Step #3 above does this automatically when CI tests are set up.
38
+
39
+ If you agree with the lint suggestions, you can run `npm run lint:fix` and the changes will be made to your files automatically.
40
+
41
+ You can add custom rules to your .eslintrc file.
42
+
43
+ <!-- leave these buried at the bottom of the document -->
44
+
45
+ [ci-img]: https://github.com/haraka/haraka-eslint/actions/workflows/ci.yml/badge.svg
46
+ [ci-url]: https://github.com/haraka/haraka-eslint/actions/workflows/ci.yml
47
+ [clim-img]: https://codeclimate.com/github/haraka/haraka-eslint/badges/gpa.svg
48
+ [clim-url]: https://codeclimate.com/github/haraka/haraka-eslint
49
+ [npm-img]: https://nodei.co/npm/eslint-plugin-haraka.png
50
+ [npm-url]: https://www.npmjs.com/package/eslint-plugin-haraka
package/index.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ // 0 = off
4
+ // 1 = warn
5
+ // 2 = error
6
+
7
+ const envs = {
8
+ node: true,
9
+ es6: true,
10
+ mocha: true,
11
+ };
12
+
13
+ const globals = {
14
+ OK: true,
15
+ CONT: true,
16
+ DENY: true,
17
+ DENYSOFT: true,
18
+ DENYDISCONNECT: true,
19
+ DENYSOFTDISCONNECT: true,
20
+ };
21
+
22
+ const recommendedRules = {
23
+ "dot-notation": "error",
24
+ "one-var": ["error", "never"],
25
+ "no-empty": ["error", { allowEmptyCatch: true }],
26
+ "no-shadow": "error",
27
+ "no-undef": "warn",
28
+ "no-unused-vars": ["warn", { args: "none" }],
29
+ "no-console": "off",
30
+ "no-path-concat": "error",
31
+ "no-cond-assign": ["error", "except-parens"],
32
+ "no-constant-condition": ["error", { checkLoops: false }],
33
+ "prefer-const": ["error", { ignoreReadBeforeAssign: true }],
34
+ "no-var": "error",
35
+ "object-shorthand": ["warn", "always"],
36
+ "prefer-template": "warn",
37
+ };
38
+
39
+ module.exports = {
40
+ env: envs,
41
+ root: true,
42
+ extends: "eslint:recommended",
43
+ globals: globals,
44
+ rules: {
45
+ "no-newline-no-curly-if": require("./rules/no-newline-no-curly-if"),
46
+ },
47
+ configs: {
48
+ recommended: {
49
+ env: envs,
50
+ extends: "eslint:recommended",
51
+ globals: globals,
52
+ rules: recommendedRules,
53
+ },
54
+ },
55
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@haraka/eslint-config",
3
+ "version": "1.1.0",
4
+ "description": "eslint config for Haraka projects",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintconfig"
8
+ ],
9
+ "main": "index.js",
10
+ "files": [
11
+ "CHANGELOG.md",
12
+ "rules"
13
+ ],
14
+ "scripts": {
15
+ "format": "npm run prettier:fix && npm run lint:fix",
16
+ "lint": "npx eslint@8 *.js **/*.js",
17
+ "lint:fix": "npm run lint -- --fix",
18
+ "prettier": "npx prettier . --check",
19
+ "prettier:fix": "npx prettier . --write",
20
+ "test": "node index.js"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/haraka/haraka-eslint.git"
25
+ },
26
+ "keywords": [
27
+ "haraka",
28
+ "lint",
29
+ "eslint",
30
+ "test"
31
+ ],
32
+ "author": "Matt Simerson <matt@tnpi.net>",
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/haraka/haraka-eslint/issues"
36
+ },
37
+ "homepage": "https://github.com/haraka/haraka-eslint#readme",
38
+ "devDependencies": {},
39
+ "peerDependencies": {
40
+ "eslint": "^8.0.0"
41
+ }
42
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ exports.meta = {
4
+ docs: {
5
+ description: "disallow if() with a single following line and no curlies",
6
+ category: "Possible Errors",
7
+ recommended: true,
8
+ },
9
+ fixable: "code",
10
+ schema: [], // no options
11
+ };
12
+
13
+ exports.create = function (context) {
14
+ const sourceCode = context.getSourceCode();
15
+ const sourceText = sourceCode.getText();
16
+
17
+ return {
18
+ IfStatement(node) {
19
+ if (node.parent.type !== "IfStatement") {
20
+ if (node.consequent.type != "BlockStatement") {
21
+ // console.log(node);
22
+ if (
23
+ sourceText.charCodeAt(
24
+ sourceCode.getTokenBefore(node.consequent).end,
25
+ ) == 10
26
+ ) {
27
+ context.report({
28
+ node: node,
29
+ message: "Newline after if with no curly",
30
+ });
31
+ }
32
+ }
33
+ }
34
+ },
35
+ };
36
+ };