@jobscale/eslint-plugin-standard 0.0.1

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.
@@ -0,0 +1,158 @@
1
+ name: Docker
2
+
3
+ # This workflow uses actions that are not certified by GitHub.
4
+ # They are provided by a third-party and are governed by
5
+ # separate terms of service, privacy policy, and support
6
+ # documentation.
7
+
8
+ # The workflow was triggered 195 times via automatically.
9
+
10
+ on:
11
+ # schedule:
12
+ # - cron: '12 17 * * 1'
13
+ push:
14
+ branches: [ main ]
15
+ # Publish semver tags as releases.
16
+ tags: [ 'v*.*.*' ]
17
+ pull_request:
18
+ branches: [ main ]
19
+
20
+ env:
21
+ # Use docker.io for Docker Hub if empty
22
+ REGISTRY: ghcr.io
23
+ # github.repository as <account>/<repo>
24
+ IMAGE_NAME: ${{ github.repository }}
25
+ PLATFORMS: linux/amd64,linux/arm64
26
+
27
+ jobs:
28
+ build:
29
+ runs-on: ubuntu-latest
30
+ strategy:
31
+ matrix:
32
+ include:
33
+ - name: regular
34
+ irregular: ''
35
+ docker_file: Dockerfile
36
+
37
+ permissions:
38
+ contents: read
39
+ packages: write
40
+
41
+ steps:
42
+ - name: Build ${{ matrix.name }}
43
+ run: echo "Build for ${{ matrix.name }}"
44
+
45
+ - name: Checkout repository
46
+ uses: actions/checkout@v2
47
+
48
+ - name: Set up QEMU
49
+ uses: docker/setup-qemu-action@v1
50
+
51
+ - name: Set up Docker Buildx
52
+ uses: docker/setup-buildx-action@v1
53
+
54
+ # Login against a Docker registry except on PR
55
+ # https://github.com/docker/login-action
56
+ - name: Log into registry ${{ env.REGISTRY }}
57
+ if: github.event_name != 'pull_request'
58
+ uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
59
+ with:
60
+ registry: ${{ env.REGISTRY }}
61
+ username: ${{ github.actor }}
62
+ password: ${{ secrets.GITHUB_TOKEN }}
63
+
64
+ - name: Set Custom Environment ${{ matrix.name }}
65
+ run: |
66
+ if [[ -n "${{ matrix.irregular }}" ]]; then
67
+ SUFFIX="-${{ matrix.irregular }}"
68
+ GH_DEFAULT=${{ matrix.irregular }}
69
+ else
70
+ SUFFIX=""
71
+ GH_DEFAULT=latest
72
+ fi
73
+
74
+ if [[ "$GITHUB_REF" == refs/heads/* ]]; then
75
+ GH_EVENT="${GITHUB_REF#refs/heads/}"
76
+ elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
77
+ GH_EVENT="${GITHUB_REF#refs/tags/}"
78
+ else
79
+ GH_EVENT="num.${{ github.event.pull_request.number || github.event.number || 'unknown' }}"
80
+ fi
81
+
82
+ # latest or irregular
83
+ echo "GH_DEFAULT=${GH_DEFAULT}" >> $GITHUB_ENV
84
+ # short_sha or short_sha-irregular
85
+ echo "SHORT_SHA=${GITHUB_SHA::7}${SUFFIX}" >> $GITHUB_ENV
86
+ # date or date-irregular
87
+ echo "GH_DATE=$(date +%Y-%m-%d)${SUFFIX}" >> $GITHUB_ENV
88
+ # rev or rev-irregular
89
+ echo "GH_REV=rev.${GITHUB_RUN_NUMBER}${SUFFIX}" >> $GITHUB_ENV
90
+ # main or main-irregular
91
+ echo "GH_EVENT=${GH_EVENT}${SUFFIX}" >> $GITHUB_ENV
92
+ env:
93
+ IRREGULAR: ${{ matrix.irregular }}
94
+
95
+ # Extract metadata (tags, labels) for Docker
96
+ # https://github.com/docker/metadata-action
97
+ - name: Extract Docker metadata
98
+ id: meta
99
+ uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
100
+ with:
101
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
102
+ tags: |
103
+ type=raw,value=${{ env.GH_DEFAULT }}
104
+ type=raw,value=${{ env.GH_EVENT }}
105
+ type=raw,value=${{ env.GH_REV }}
106
+ type=raw,value=${{ env.SHORT_SHA }}
107
+ type=raw,value=${{ env.GH_DATE }}
108
+
109
+ # Build and push Docker image with Buildx (don't push on PR)
110
+ # https://github.com/docker/build-push-action
111
+ - name: Build and push Docker image
112
+ uses: docker/build-push-action@v2
113
+ with:
114
+ context: .
115
+ push: ${{ github.event_name != 'pull_request' }}
116
+ platforms: ${{ env.PLATFORMS }}
117
+ tags: ${{ steps.meta.outputs.tags }}
118
+ labels: ${{ steps.meta.outputs.labels }}
119
+ file: ${{ matrix.docker_file }}
120
+ cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.GH_DEFAULT }}
121
+ cache-to: type=inline
122
+
123
+ - name: Slack post ${{ matrix.name }}
124
+ run: |
125
+ cat /etc/os-release
126
+ $(echo $SHELL) --version
127
+ id
128
+ free -h
129
+ df -h .
130
+ grep MH /proc/cpuinfo
131
+ pwd
132
+ ls -la
133
+ GIP=$(curl -s https://inet-ip.info/ip)
134
+ echo "Global: $GIP"
135
+ LABELS=$(echo "${{ steps.meta.outputs.labels }}" | grep -E 'image\.title=|image\.source=' | sed -E 's/org.opencontainers.image.[a-z]+=//' | xargs)
136
+ if [[ -n "${{ matrix.irregular }}" ]]; then
137
+ LABELS="$(echo $LABELS | sed -e "s/ / [ ${{ matrix.irregular }} ] /")"
138
+ fi
139
+ TAGS=$(echo "${{ steps.meta.outputs.tags }}" | grep -v -E 'latest')
140
+ STAMP=$(TZ=Asia/Tokyo date -Iseconds)
141
+ MESSAGE="$STAMP - $GIP\n$LABELS\n$TAGS"
142
+ DATA=$(echo -e "$MESSAGE" | sed -z -e 's/\n/\\n/g')
143
+ curl -is -X POST -H 'Content-Type: application/json' \
144
+ https://jsx.jp/api/slack \
145
+ --data "{\"icon_emoji\":\":whale:\",\"username\":\"GitHub\",\"text\":\"$DATA\",\"channel\":\"container\"}" || echo
146
+
147
+ - name: Failure post ${{ matrix.name }}
148
+ if: failure()
149
+ run: |
150
+ LABELS=$(echo "${{ steps.meta.outputs.labels }}" | grep -E 'image\.title=|image\.source=' | sed -E 's/org.opencontainers.image.[a-z]+=//' | xargs)
151
+ if [[ -n "${{ matrix.irregular }}" ]]; then
152
+ LABELS="$(echo $LABELS | sed -e "s/ / [ ${{ matrix.irregular }} ] /")"
153
+ fi
154
+ MESSAGE="$LABELS\nFailed ${{ matrix.name }} $(TZ=Asia/Tokyo date -Iseconds)"
155
+ DATA=$(echo -e "$MESSAGE" | sed -z -e 's/\n/\\n/g')
156
+ curl -is -X POST -H 'Content-Type: application/json' \
157
+ https://jsx.jp/api/slack \
158
+ --data "{\"icon_emoji\":\":whale:\",\"username\":\"GitHub\",\"text\":\"$DATA\",\"channel\":\"push\"}" || echo
@@ -0,0 +1,35 @@
1
+ name: Nodejs CI
2
+
3
+ on: [ push ]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ matrix:
12
+ node-version: [ 20.x, 22.x, 24.x ]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v1
16
+ - name: Use Node.js ${{ matrix.node-version }}
17
+ uses: actions/setup-node@v1
18
+ with:
19
+ node-version: ${{ matrix.node-version }}
20
+ - name: npm install, build, and test
21
+ run: |
22
+ cat /etc/*release
23
+ grep MH /proc/cpuinfo
24
+ free -h
25
+ curl https://inet-ip.info/ip
26
+ npm i
27
+ npm run build --if-present
28
+ npm run lint --if-present
29
+ npm test
30
+ IMAGE=my-image-name:$(date +%s)
31
+ docker build . --file Dockerfile --tag $IMAGE
32
+ docker run --rm -i $IMAGE --help
33
+ docker run --rm -i $IMAGE
34
+ env:
35
+ CI: true
package/Dockerfile ADDED
@@ -0,0 +1,11 @@
1
+ FROM node:lts-trixie-slim
2
+ SHELL ["bash", "-c"]
3
+ WORKDIR /home/node
4
+ USER node
5
+ COPY --chown=node:staff package.json .
6
+ RUN npm i --omit=dev
7
+ COPY --chown=node:staff eslint.config.js .
8
+ COPY --chown=node:staff rules rules
9
+ COPY --chown=node:staff index.js .
10
+ COPY --chown=node:staff app app
11
+ CMD ["npm", "run", "lint"]
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # ESLint Plugin Standard
2
+
3
+ ## ESLint v9
4
+
5
+ ### Install
6
+
7
+ ```
8
+ npm i -D @jobscale/eslint-plugin-standard
9
+ ```
10
+
11
+ ### eslint.config.js
12
+
13
+ ```
14
+ import standard from '@jobscale/eslint-plugin-standard';
15
+
16
+ export default [
17
+ standard.configs.standard,
18
+ ];
19
+ ```
20
+
21
+ ## Docker Examples
22
+
23
+ ```
24
+ docker pull jobscale/eslint-plugin-standard
25
+ ```
26
+
27
+ ### Build
28
+
29
+ ```
30
+ docker build . -t jobscale/eslint-plugin-standard
31
+ ```
32
+
33
+ ### lint
34
+
35
+ ```
36
+ docker run --rm -v $(pwd):/home/node/task -it jobscale/eslint-plugin-standard
37
+ ```
38
+
39
+ ### lint fix
40
+
41
+ ```
42
+ docker run --rm -v $(pwd):/home/node/task -it jobscale/eslint-plugin-standard npm run lint -- --fix
43
+ ```
package/app/index.js ADDED
@@ -0,0 +1,54 @@
1
+ const https = require('https');
2
+ const http = require('http');
3
+ const { HttpsProxyAgent } = require('https-proxy-agent');
4
+ const { HttpProxyAgent } = require('http-proxy-agent');
5
+
6
+ class App {
7
+ get logger() {
8
+ const logger = {};
9
+ Object.entries(console).forEach(([key, value]) => {
10
+ logger[key] = (...argv) => value(`[${key.toUpperCase()}]`, ...argv);
11
+ });
12
+ return logger;
13
+ }
14
+
15
+ promiseGen() {
16
+ const prom = {};
17
+ prom.pending = new Promise((...argv) => { [prom.resolve, prom.reject] = argv; });
18
+ return prom;
19
+ }
20
+
21
+ async fetch(url, options) {
22
+ const instanceOptions = {};
23
+ Object.assign(instanceOptions, options);
24
+ const [protocol] = url.split(':');
25
+ const proxy = process.env[`${protocol}_proxy`];
26
+ if (proxy) {
27
+ const Agent = { https: HttpsProxyAgent, http: HttpProxyAgent };
28
+ instanceOptions.agent = new Agent[protocol](proxy);
29
+ }
30
+ const prom = this.promiseGen();
31
+ const fetch = { https, http };
32
+ fetch[protocol].get(url, instanceOptions, res => {
33
+ const { statusCode, statusMessage } = res;
34
+ const chunked = [];
35
+ res.on('data', chunk => {
36
+ chunked.push(chunk);
37
+ });
38
+ res.on('end', () => {
39
+ prom.resolve({
40
+ statusCode, statusMessage, body: chunked.join(''),
41
+ });
42
+ });
43
+ res.on('error', e => {
44
+ prom.reject(e);
45
+ });
46
+ });
47
+ return prom.pending;
48
+ }
49
+ }
50
+
51
+ export default {
52
+ app: new App(),
53
+ App,
54
+ };
@@ -0,0 +1,5 @@
1
+ import standard from './index.js';
2
+
3
+ export default [
4
+ standard.configs.standard,
5
+ ];
package/index.js ADDED
@@ -0,0 +1,49 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+
4
+ import airbnb1 from "./rules/best-practices.js";
5
+ import airbnb2 from "./rules/strict.js";
6
+ import airbnb3 from "./rules/es6.js";
7
+ import airbnb4 from "./rules/errors.js";
8
+ import airbnb5 from "./rules/node.js";
9
+
10
+ const recommended = {
11
+ name: "eslint-plugin-standard/recommended",
12
+ files: ["**/*.{js,mjs}"],
13
+ languageOptions: {
14
+ ecmaVersion: 'latest',
15
+ sourceType: "module",
16
+ globals: {
17
+ ...globals.browser,
18
+ ...globals.node,
19
+ ...globals.jest,
20
+ },
21
+ },
22
+ rules: {
23
+ ...airbnb1.rules,
24
+ ...airbnb2.rules,
25
+ ...airbnb3.rules,
26
+ ...airbnb4.rules,
27
+ ...airbnb5.rules,
28
+ indent: ["error", 2, { MemberExpression: 0 }],
29
+ "class-methods-use-this": "off",
30
+ "no-await-in-loop": "off",
31
+ "arrow-parens": "off",
32
+ },
33
+ };
34
+
35
+ const standard = {
36
+ ...recommended,
37
+ rules: {
38
+ ...pluginJs.configs.recommended.rules,
39
+ ...recommended.rules,
40
+ },
41
+ };
42
+
43
+ export default {
44
+ rules: {},
45
+ configs: {
46
+ recommended,
47
+ standard,
48
+ },
49
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@jobscale/eslint-plugin-standard",
3
+ "version": "0.0.1",
4
+ "description": "eslint plugin standard",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintplugin",
8
+ "eslint-config",
9
+ "eslint-style",
10
+ "eslint-standard"
11
+ ],
12
+ "author": "jobscale <jobscale@users.noreply.github.com>",
13
+ "license": "MIT",
14
+ "type": "module",
15
+ "main": "index.js",
16
+ "scripts": {
17
+ "start": "eslint",
18
+ "lint": "eslint",
19
+ "test": "npm run lint"
20
+ },
21
+ "pre-commit": ["test"],
22
+ "dependencies": {
23
+ "eslint-plugin-import": "^2"
24
+ },
25
+ "devDependencies": {
26
+ "eslint": "^9",
27
+ "precommit": "^1"
28
+ }
29
+ }
@@ -0,0 +1,408 @@
1
+ export default {
2
+ rules: {
3
+ // enforces getter/setter pairs in objects
4
+ // https://eslint.org/docs/rules/accessor-pairs
5
+ 'accessor-pairs': 'off',
6
+
7
+ // enforces return statements in callbacks of array's methods
8
+ // https://eslint.org/docs/rules/array-callback-return
9
+ 'array-callback-return': ['error', { allowImplicit: true }],
10
+
11
+ // treat var statements as if they were block scoped
12
+ // https://eslint.org/docs/rules/block-scoped-var
13
+ 'block-scoped-var': 'error',
14
+
15
+ // specify the maximum cyclomatic complexity allowed in a program
16
+ // https://eslint.org/docs/rules/complexity
17
+ complexity: ['off', 20],
18
+
19
+ // enforce that class methods use "this"
20
+ // https://eslint.org/docs/rules/class-methods-use-this
21
+ 'class-methods-use-this': ['error', {
22
+ exceptMethods: [],
23
+ }],
24
+
25
+ // require return statements to either always or never specify values
26
+ // https://eslint.org/docs/rules/consistent-return
27
+ 'consistent-return': 'error',
28
+
29
+ // specify curly brace conventions for all control statements
30
+ // https://eslint.org/docs/rules/curly
31
+ curly: ['error', 'multi-line'], // multiline
32
+
33
+ // require default case in switch statements
34
+ // https://eslint.org/docs/rules/default-case
35
+ 'default-case': ['error', { commentPattern: '^no default$' }],
36
+
37
+ // Enforce default clauses in switch statements to be last
38
+ // https://eslint.org/docs/rules/default-case-last
39
+ 'default-case-last': 'error',
40
+
41
+ // https://eslint.org/docs/rules/default-param-last
42
+ 'default-param-last': 'error',
43
+
44
+ // encourages use of dot notation whenever possible
45
+ // https://eslint.org/docs/rules/dot-notation
46
+ 'dot-notation': ['error', { allowKeywords: true }],
47
+
48
+ // enforces consistent newlines before or after dots
49
+ // https://eslint.org/docs/rules/dot-location
50
+ 'dot-location': ['error', 'property'],
51
+
52
+ // require the use of === and !==
53
+ // https://eslint.org/docs/rules/eqeqeq
54
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
55
+
56
+ // Require grouped accessor pairs in object literals and classes
57
+ // https://eslint.org/docs/rules/grouped-accessor-pairs
58
+ 'grouped-accessor-pairs': 'error',
59
+
60
+ // make sure for-in loops have an if statement
61
+ // https://eslint.org/docs/rules/guard-for-in
62
+ 'guard-for-in': 'error',
63
+
64
+ // enforce a maximum number of classes per file
65
+ // https://eslint.org/docs/rules/max-classes-per-file
66
+ 'max-classes-per-file': ['error', 1],
67
+
68
+ // disallow the use of alert, confirm, and prompt
69
+ // https://eslint.org/docs/rules/no-alert
70
+ 'no-alert': 'warn',
71
+
72
+ // disallow use of arguments.caller or arguments.callee
73
+ // https://eslint.org/docs/rules/no-caller
74
+ 'no-caller': 'error',
75
+
76
+ // disallow lexical declarations in case/default clauses
77
+ // https://eslint.org/docs/rules/no-case-declarations
78
+ 'no-case-declarations': 'error',
79
+
80
+ // Disallow returning value in constructor
81
+ // https://eslint.org/docs/rules/no-constructor-return
82
+ 'no-constructor-return': 'error',
83
+
84
+ // disallow division operators explicitly at beginning of regular expression
85
+ // https://eslint.org/docs/rules/no-div-regex
86
+ 'no-div-regex': 'off',
87
+
88
+ // disallow else after a return in an if
89
+ // https://eslint.org/docs/rules/no-else-return
90
+ 'no-else-return': ['error', { allowElseIf: false }],
91
+
92
+ // disallow empty functions, except for standalone funcs/arrows
93
+ // https://eslint.org/docs/rules/no-empty-function
94
+ 'no-empty-function': ['error', {
95
+ allow: [
96
+ 'arrowFunctions',
97
+ 'functions',
98
+ 'methods',
99
+ ]
100
+ }],
101
+
102
+ // disallow empty destructuring patterns
103
+ // https://eslint.org/docs/rules/no-empty-pattern
104
+ 'no-empty-pattern': 'error',
105
+
106
+ // disallow comparisons to null without a type-checking operator
107
+ // https://eslint.org/docs/rules/no-eq-null
108
+ 'no-eq-null': 'off',
109
+
110
+ // disallow use of eval()
111
+ // https://eslint.org/docs/rules/no-eval
112
+ 'no-eval': 'error',
113
+
114
+ // disallow adding to native types
115
+ // https://eslint.org/docs/rules/no-extend-native
116
+ 'no-extend-native': 'error',
117
+
118
+ // disallow unnecessary function binding
119
+ // https://eslint.org/docs/rules/no-extra-bind
120
+ 'no-extra-bind': 'error',
121
+
122
+ // disallow Unnecessary Labels
123
+ // https://eslint.org/docs/rules/no-extra-label
124
+ 'no-extra-label': 'error',
125
+
126
+ // disallow fallthrough of case statements
127
+ // https://eslint.org/docs/rules/no-fallthrough
128
+ 'no-fallthrough': 'error',
129
+
130
+ // disallow the use of leading or trailing decimal points in numeric literals
131
+ // https://eslint.org/docs/rules/no-floating-decimal
132
+ 'no-floating-decimal': 'error',
133
+
134
+ // disallow reassignments of native objects or read-only globals
135
+ // https://eslint.org/docs/rules/no-global-assign
136
+ 'no-global-assign': ['error', { exceptions: [] }],
137
+
138
+ // deprecated in favor of no-global-assign
139
+ // https://eslint.org/docs/rules/no-native-reassign
140
+ 'no-native-reassign': 'off',
141
+
142
+ // disallow implicit type conversions
143
+ // https://eslint.org/docs/rules/no-implicit-coercion
144
+ 'no-implicit-coercion': ['off', {
145
+ boolean: false,
146
+ number: true,
147
+ string: true,
148
+ allow: [],
149
+ }],
150
+
151
+ // disallow var and named functions in global scope
152
+ // https://eslint.org/docs/rules/no-implicit-globals
153
+ 'no-implicit-globals': 'off',
154
+
155
+ // disallow use of eval()-like methods
156
+ // https://eslint.org/docs/rules/no-implied-eval
157
+ 'no-implied-eval': 'error',
158
+
159
+ // disallow this keywords outside of classes or class-like objects
160
+ // https://eslint.org/docs/rules/no-invalid-this
161
+ 'no-invalid-this': 'off',
162
+
163
+ // disallow usage of __iterator__ property
164
+ // https://eslint.org/docs/rules/no-iterator
165
+ 'no-iterator': 'error',
166
+
167
+ // disallow use of labels for anything other than loops and switches
168
+ // https://eslint.org/docs/rules/no-labels
169
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
170
+
171
+ // disallow unnecessary nested blocks
172
+ // https://eslint.org/docs/rules/no-lone-blocks
173
+ 'no-lone-blocks': 'error',
174
+
175
+ // disallow creation of functions within loops
176
+ // https://eslint.org/docs/rules/no-loop-func
177
+ 'no-loop-func': 'error',
178
+
179
+ // disallow magic numbers
180
+ // https://eslint.org/docs/rules/no-magic-numbers
181
+ 'no-magic-numbers': ['off', {
182
+ ignore: [],
183
+ ignoreArrayIndexes: true,
184
+ enforceConst: true,
185
+ detectObjects: false,
186
+ }],
187
+
188
+ // disallow use of multiple spaces
189
+ // https://eslint.org/docs/rules/no-multi-spaces
190
+ 'no-multi-spaces': ['error', {
191
+ ignoreEOLComments: false,
192
+ }],
193
+
194
+ // disallow use of multiline strings
195
+ // https://eslint.org/docs/rules/no-multi-str
196
+ 'no-multi-str': 'error',
197
+
198
+ // disallow use of new operator when not part of the assignment or comparison
199
+ // https://eslint.org/docs/rules/no-new
200
+ 'no-new': 'error',
201
+
202
+ // disallow use of new operator for Function object
203
+ // https://eslint.org/docs/rules/no-new-func
204
+ 'no-new-func': 'error',
205
+
206
+ // disallows creating new instances of String, Number, and Boolean
207
+ // https://eslint.org/docs/rules/no-new-wrappers
208
+ 'no-new-wrappers': 'error',
209
+
210
+ // Disallow \8 and \9 escape sequences in string literals
211
+ // https://eslint.org/docs/rules/no-nonoctal-decimal-escape
212
+ 'no-nonoctal-decimal-escape': 'error',
213
+
214
+ // disallow use of (old style) octal literals
215
+ // https://eslint.org/docs/rules/no-octal
216
+ 'no-octal': 'error',
217
+
218
+ // disallow use of octal escape sequences in string literals, such as
219
+ // var foo = 'Copyright \251';
220
+ // https://eslint.org/docs/rules/no-octal-escape
221
+ 'no-octal-escape': 'error',
222
+
223
+ // disallow reassignment of function parameters
224
+ // disallow parameter object manipulation except for specific exclusions
225
+ // rule: https://eslint.org/docs/rules/no-param-reassign.html
226
+ 'no-param-reassign': ['error', {
227
+ props: true,
228
+ ignorePropertyModificationsFor: [
229
+ 'acc', // for reduce accumulators
230
+ 'accumulator', // for reduce accumulators
231
+ 'e', // for e.returnvalue
232
+ 'ctx', // for Koa routing
233
+ 'context', // for Koa routing
234
+ 'req', // for Express requests
235
+ 'request', // for Express requests
236
+ 'res', // for Express responses
237
+ 'response', // for Express responses
238
+ '$scope', // for Angular 1 scopes
239
+ 'staticContext', // for ReactRouter context
240
+ ]
241
+ }],
242
+
243
+ // disallow usage of __proto__ property
244
+ // https://eslint.org/docs/rules/no-proto
245
+ 'no-proto': 'error',
246
+
247
+ // disallow declaring the same variable more than once
248
+ // https://eslint.org/docs/rules/no-redeclare
249
+ 'no-redeclare': 'error',
250
+
251
+ // disallow certain object properties
252
+ // https://eslint.org/docs/rules/no-restricted-properties
253
+ 'no-restricted-properties': ['error', {
254
+ object: 'arguments',
255
+ property: 'callee',
256
+ message: 'arguments.callee is deprecated',
257
+ }, {
258
+ object: 'global',
259
+ property: 'isFinite',
260
+ message: 'Please use Number.isFinite instead',
261
+ }, {
262
+ object: 'self',
263
+ property: 'isFinite',
264
+ message: 'Please use Number.isFinite instead',
265
+ }, {
266
+ object: 'window',
267
+ property: 'isFinite',
268
+ message: 'Please use Number.isFinite instead',
269
+ }, {
270
+ object: 'global',
271
+ property: 'isNaN',
272
+ message: 'Please use Number.isNaN instead',
273
+ }, {
274
+ object: 'self',
275
+ property: 'isNaN',
276
+ message: 'Please use Number.isNaN instead',
277
+ }, {
278
+ object: 'window',
279
+ property: 'isNaN',
280
+ message: 'Please use Number.isNaN instead',
281
+ }, {
282
+ property: '__defineGetter__',
283
+ message: 'Please use Object.defineProperty instead.',
284
+ }, {
285
+ property: '__defineSetter__',
286
+ message: 'Please use Object.defineProperty instead.',
287
+ }, {
288
+ object: 'Math',
289
+ property: 'pow',
290
+ message: 'Use the exponentiation operator (**) instead.',
291
+ }],
292
+
293
+ // disallow use of assignment in return statement
294
+ // https://eslint.org/docs/rules/no-return-assign
295
+ 'no-return-assign': ['error', 'always'],
296
+
297
+ // disallow redundant `return await`
298
+ // https://eslint.org/docs/rules/no-return-await
299
+ 'no-return-await': 'error',
300
+
301
+ // disallow use of `javascript:` urls.
302
+ // https://eslint.org/docs/rules/no-script-url
303
+ 'no-script-url': 'error',
304
+
305
+ // disallow self assignment
306
+ // https://eslint.org/docs/rules/no-self-assign
307
+ 'no-self-assign': ['error', {
308
+ props: true,
309
+ }],
310
+
311
+ // disallow comparisons where both sides are exactly the same
312
+ // https://eslint.org/docs/rules/no-self-compare
313
+ 'no-self-compare': 'error',
314
+
315
+ // disallow use of comma operator
316
+ // https://eslint.org/docs/rules/no-sequences
317
+ 'no-sequences': 'error',
318
+
319
+ // restrict what can be thrown as an exception
320
+ // https://eslint.org/docs/rules/no-throw-literal
321
+ 'no-throw-literal': 'error',
322
+
323
+ // disallow unmodified conditions of loops
324
+ // https://eslint.org/docs/rules/no-unmodified-loop-condition
325
+ 'no-unmodified-loop-condition': 'off',
326
+
327
+ // disallow usage of expressions in statement position
328
+ // https://eslint.org/docs/rules/no-unused-expressions
329
+ 'no-unused-expressions': ['error', {
330
+ allowShortCircuit: false,
331
+ allowTernary: false,
332
+ allowTaggedTemplates: false,
333
+ }],
334
+
335
+ // disallow unused labels
336
+ // https://eslint.org/docs/rules/no-unused-labels
337
+ 'no-unused-labels': 'error',
338
+
339
+ // disallow unnecessary .call() and .apply()
340
+ // https://eslint.org/docs/rules/no-useless-call
341
+ 'no-useless-call': 'off',
342
+
343
+ // Disallow unnecessary catch clauses
344
+ // https://eslint.org/docs/rules/no-useless-catch
345
+ 'no-useless-catch': 'error',
346
+
347
+ // disallow useless string concatenation
348
+ // https://eslint.org/docs/rules/no-useless-concat
349
+ 'no-useless-concat': 'error',
350
+
351
+ // disallow unnecessary string escaping
352
+ // https://eslint.org/docs/rules/no-useless-escape
353
+ 'no-useless-escape': 'error',
354
+
355
+ // disallow redundant return; keywords
356
+ // https://eslint.org/docs/rules/no-useless-return
357
+ 'no-useless-return': 'error',
358
+
359
+ // disallow use of void operator
360
+ // https://eslint.org/docs/rules/no-void
361
+ 'no-void': 'error',
362
+
363
+ // disallow usage of configurable warning terms in comments: e.g. todo
364
+ // https://eslint.org/docs/rules/no-warning-comments
365
+ 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
366
+
367
+ // disallow use of the with statement
368
+ // https://eslint.org/docs/rules/no-with
369
+ 'no-with': 'error',
370
+
371
+ // require using Error objects as Promise rejection reasons
372
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
373
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
374
+
375
+ // Suggest using named capture group in regular expression
376
+ // https://eslint.org/docs/rules/prefer-named-capture-group
377
+ 'prefer-named-capture-group': 'off',
378
+
379
+ // https://eslint.org/docs/rules/prefer-regex-literals
380
+ 'prefer-regex-literals': ['error', {
381
+ disallowRedundantWrapping: true,
382
+ }],
383
+
384
+ // require use of the second argument for parseInt()
385
+ // https://eslint.org/docs/rules/radix
386
+ radix: 'error',
387
+
388
+ // require `await` in `async function` (note: this is a horrible rule that should never be used)
389
+ // https://eslint.org/docs/rules/require-await
390
+ 'require-await': 'off',
391
+
392
+ // Enforce the use of u flag on RegExp
393
+ // https://eslint.org/docs/rules/require-unicode-regexp
394
+ 'require-unicode-regexp': 'off',
395
+
396
+ // requires to declare all vars on top of their containing scope
397
+ // https://eslint.org/docs/rules/vars-on-top
398
+ 'vars-on-top': 'error',
399
+
400
+ // require immediate function invocation to be wrapped in parentheses
401
+ // https://eslint.org/docs/rules/wrap-iife.html
402
+ 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
403
+
404
+ // require or disallow Yoda conditions
405
+ // https://eslint.org/docs/rules/yoda
406
+ yoda: 'error'
407
+ }
408
+ };
@@ -0,0 +1,179 @@
1
+ export default {
2
+ rules: {
3
+ // Enforce “for” loop update clause moving the counter in the right direction
4
+ // https://eslint.org/docs/rules/for-direction
5
+ 'for-direction': 'error',
6
+
7
+ // Enforces that a return statement is present in property getters
8
+ // https://eslint.org/docs/rules/getter-return
9
+ 'getter-return': ['error', { allowImplicit: true }],
10
+
11
+ // disallow using an async function as a Promise executor
12
+ // https://eslint.org/docs/rules/no-async-promise-executor
13
+ 'no-async-promise-executor': 'error',
14
+
15
+ // Disallow await inside of loops
16
+ // https://eslint.org/docs/rules/no-await-in-loop
17
+ 'no-await-in-loop': 'error',
18
+
19
+ // Disallow comparisons to negative zero
20
+ // https://eslint.org/docs/rules/no-compare-neg-zero
21
+ 'no-compare-neg-zero': 'error',
22
+
23
+ // disallow assignment in conditional expressions
24
+ 'no-cond-assign': ['error', 'always'],
25
+
26
+ // disallow use of console
27
+ 'no-console': 'warn',
28
+
29
+ // disallow use of constant expressions in conditions
30
+ 'no-constant-condition': 'warn',
31
+
32
+ // disallow control characters in regular expressions
33
+ 'no-control-regex': 'error',
34
+
35
+ // disallow use of debugger
36
+ 'no-debugger': 'error',
37
+
38
+ // disallow duplicate arguments in functions
39
+ 'no-dupe-args': 'error',
40
+
41
+ // Disallow duplicate conditions in if-else-if chains
42
+ // https://eslint.org/docs/rules/no-dupe-else-if
43
+ 'no-dupe-else-if': 'error',
44
+
45
+ // disallow duplicate keys when creating object literals
46
+ 'no-dupe-keys': 'error',
47
+
48
+ // disallow a duplicate case label.
49
+ 'no-duplicate-case': 'error',
50
+
51
+ // disallow empty statements
52
+ 'no-empty': 'error',
53
+
54
+ // disallow the use of empty character classes in regular expressions
55
+ 'no-empty-character-class': 'error',
56
+
57
+ // disallow assigning to the exception in a catch block
58
+ 'no-ex-assign': 'error',
59
+
60
+ // disallow double-negation boolean casts in a boolean context
61
+ // https://eslint.org/docs/rules/no-extra-boolean-cast
62
+ 'no-extra-boolean-cast': 'error',
63
+
64
+ // disallow unnecessary parentheses
65
+ // https://eslint.org/docs/rules/no-extra-parens
66
+ 'no-extra-parens': ['off', 'all', {
67
+ conditionalAssign: true,
68
+ nestedBinaryExpressions: false,
69
+ returnAssign: false,
70
+ ignoreJSX: 'all', // delegate to eslint-plugin-react
71
+ enforceForArrowConditionals: false,
72
+ }],
73
+
74
+ // disallow unnecessary semicolons
75
+ 'no-extra-semi': 'error',
76
+
77
+ // disallow overwriting functions written as function declarations
78
+ 'no-func-assign': 'error',
79
+
80
+ // https://eslint.org/docs/rules/no-import-assign
81
+ 'no-import-assign': 'error',
82
+
83
+ // disallow function or variable declarations in nested blocks
84
+ 'no-inner-declarations': 'error',
85
+
86
+ // disallow invalid regular expression strings in the RegExp constructor
87
+ 'no-invalid-regexp': 'error',
88
+
89
+ // disallow irregular whitespace outside of strings and comments
90
+ 'no-irregular-whitespace': 'error',
91
+
92
+ // Disallow Number Literals That Lose Precision
93
+ // https://eslint.org/docs/rules/no-loss-of-precision
94
+ 'no-loss-of-precision': 'error',
95
+
96
+ // Disallow characters which are made with multiple code points in character class syntax
97
+ // https://eslint.org/docs/rules/no-misleading-character-class
98
+ 'no-misleading-character-class': 'error',
99
+
100
+ // disallow the use of object properties of the global object (Math and JSON) as functions
101
+ 'no-obj-calls': 'error',
102
+
103
+ // Disallow returning values from Promise executor functions
104
+ // https://eslint.org/docs/rules/no-promise-executor-return
105
+ 'no-promise-executor-return': 'error',
106
+
107
+ // disallow use of Object.prototypes builtins directly
108
+ // https://eslint.org/docs/rules/no-prototype-builtins
109
+ 'no-prototype-builtins': 'error',
110
+
111
+ // disallow multiple spaces in a regular expression literal
112
+ 'no-regex-spaces': 'error',
113
+
114
+ // Disallow returning values from setters
115
+ // https://eslint.org/docs/rules/no-setter-return
116
+ 'no-setter-return': 'error',
117
+
118
+ // disallow sparse arrays
119
+ 'no-sparse-arrays': 'error',
120
+
121
+ // Disallow template literal placeholder syntax in regular strings
122
+ // https://eslint.org/docs/rules/no-template-curly-in-string
123
+ 'no-template-curly-in-string': 'error',
124
+
125
+ // Avoid code that looks like two expressions but is actually one
126
+ // https://eslint.org/docs/rules/no-unexpected-multiline
127
+ 'no-unexpected-multiline': 'error',
128
+
129
+ // disallow unreachable statements after a return, throw, continue, or break statement
130
+ 'no-unreachable': 'error',
131
+
132
+ // Disallow loops with a body that allows only one iteration
133
+ // https://eslint.org/docs/rules/no-unreachable-loop
134
+ 'no-unreachable-loop': ['error', {
135
+ ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
136
+ }],
137
+
138
+ // disallow return/throw/break/continue inside finally blocks
139
+ // https://eslint.org/docs/rules/no-unsafe-finally
140
+ 'no-unsafe-finally': 'error',
141
+
142
+ // disallow negating the left operand of relational operators
143
+ // https://eslint.org/docs/rules/no-unsafe-negation
144
+ 'no-unsafe-negation': 'error',
145
+
146
+ // disallow use of optional chaining in contexts where the undefined value is not allowed
147
+ // https://eslint.org/docs/rules/no-unsafe-optional-chaining
148
+ 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
149
+
150
+ // Disallow Unused Private Class Members
151
+ // https://eslint.org/docs/rules/no-unused-private-class-members
152
+ // TODO: enable once eslint 7 is dropped (which is semver-major)
153
+ 'no-unused-private-class-members': 'off',
154
+
155
+ // Disallow useless backreferences in regular expressions
156
+ // https://eslint.org/docs/rules/no-useless-backreference
157
+ 'no-useless-backreference': 'error',
158
+
159
+ // disallow negation of the left operand of an in expression
160
+ // deprecated in favor of no-unsafe-negation
161
+ 'no-negated-in-lhs': 'off',
162
+
163
+ // Disallow assignments that can lead to race conditions due to usage of await or yield
164
+ // https://eslint.org/docs/rules/require-atomic-updates
165
+ // note: not enabled because it is very buggy
166
+ 'require-atomic-updates': 'off',
167
+
168
+ // disallow comparisons with the value NaN
169
+ 'use-isnan': 'error',
170
+
171
+ // ensure JSDoc comments are valid
172
+ // https://eslint.org/docs/rules/valid-jsdoc
173
+ 'valid-jsdoc': 'off',
174
+
175
+ // ensure that the results of typeof are compared against a valid string
176
+ // https://eslint.org/docs/rules/valid-typeof
177
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
178
+ }
179
+ };
package/rules/es6.js ADDED
@@ -0,0 +1,185 @@
1
+ export default {
2
+ env: {
3
+ es6: true
4
+ },
5
+ parserOptions: {
6
+ ecmaVersion: 6,
7
+ sourceType: 'module',
8
+ ecmaFeatures: {
9
+ generators: false,
10
+ objectLiteralDuplicateProperties: false
11
+ }
12
+ },
13
+
14
+ rules: {
15
+ // enforces no braces where they can be omitted
16
+ // https://eslint.org/docs/rules/arrow-body-style
17
+ // TODO: enable requireReturnForObjectLiteral?
18
+ 'arrow-body-style': ['error', 'as-needed', {
19
+ requireReturnForObjectLiteral: false,
20
+ }],
21
+
22
+ // require parens in arrow function arguments
23
+ // https://eslint.org/docs/rules/arrow-parens
24
+ 'arrow-parens': ['error', 'always'],
25
+
26
+ // require space before/after arrow function's arrow
27
+ // https://eslint.org/docs/rules/arrow-spacing
28
+ 'arrow-spacing': ['error', { before: true, after: true }],
29
+
30
+ // verify super() callings in constructors
31
+ 'constructor-super': 'error',
32
+
33
+ // enforce the spacing around the * in generator functions
34
+ // https://eslint.org/docs/rules/generator-star-spacing
35
+ 'generator-star-spacing': ['error', { before: false, after: true }],
36
+
37
+ // disallow modifying variables of class declarations
38
+ // https://eslint.org/docs/rules/no-class-assign
39
+ 'no-class-assign': 'error',
40
+
41
+ // disallow arrow functions where they could be confused with comparisons
42
+ // https://eslint.org/docs/rules/no-confusing-arrow
43
+ 'no-confusing-arrow': ['error', {
44
+ allowParens: true,
45
+ }],
46
+
47
+ // disallow modifying variables that are declared using const
48
+ 'no-const-assign': 'error',
49
+
50
+ // disallow duplicate class members
51
+ // https://eslint.org/docs/rules/no-dupe-class-members
52
+ 'no-dupe-class-members': 'error',
53
+
54
+ // disallow importing from the same path more than once
55
+ // https://eslint.org/docs/rules/no-duplicate-imports
56
+ // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
57
+ 'no-duplicate-imports': 'off',
58
+
59
+ // disallow symbol constructor
60
+ // https://eslint.org/docs/rules/no-new-symbol
61
+ 'no-new-symbol': 'error',
62
+
63
+ // Disallow specified names in exports
64
+ // https://eslint.org/docs/rules/no-restricted-exports
65
+ 'no-restricted-exports': ['error', {
66
+ restrictedNamedExports: [
67
+ 'default', // use `export default` to provide a default export
68
+ 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
69
+ ],
70
+ }],
71
+
72
+ // disallow specific imports
73
+ // https://eslint.org/docs/rules/no-restricted-imports
74
+ 'no-restricted-imports': ['off', {
75
+ paths: [],
76
+ patterns: []
77
+ }],
78
+
79
+ // disallow to use this/super before super() calling in constructors.
80
+ // https://eslint.org/docs/rules/no-this-before-super
81
+ 'no-this-before-super': 'error',
82
+
83
+ // disallow useless computed property keys
84
+ // https://eslint.org/docs/rules/no-useless-computed-key
85
+ 'no-useless-computed-key': 'error',
86
+
87
+ // disallow unnecessary constructor
88
+ // https://eslint.org/docs/rules/no-useless-constructor
89
+ 'no-useless-constructor': 'error',
90
+
91
+ // disallow renaming import, export, and destructured assignments to the same name
92
+ // https://eslint.org/docs/rules/no-useless-rename
93
+ 'no-useless-rename': ['error', {
94
+ ignoreDestructuring: false,
95
+ ignoreImport: false,
96
+ ignoreExport: false,
97
+ }],
98
+
99
+ // require let or const instead of var
100
+ 'no-var': 'error',
101
+
102
+ // require method and property shorthand syntax for object literals
103
+ // https://eslint.org/docs/rules/object-shorthand
104
+ 'object-shorthand': ['error', 'always', {
105
+ ignoreConstructors: false,
106
+ avoidQuotes: true,
107
+ }],
108
+
109
+ // suggest using arrow functions as callbacks
110
+ 'prefer-arrow-callback': ['error', {
111
+ allowNamedFunctions: false,
112
+ allowUnboundThis: true,
113
+ }],
114
+
115
+ // suggest using of const declaration for variables that are never modified after declared
116
+ 'prefer-const': ['error', {
117
+ destructuring: 'any',
118
+ ignoreReadBeforeAssign: true,
119
+ }],
120
+
121
+ // Prefer destructuring from arrays and objects
122
+ // https://eslint.org/docs/rules/prefer-destructuring
123
+ 'prefer-destructuring': ['error', {
124
+ VariableDeclarator: {
125
+ array: false,
126
+ object: true,
127
+ },
128
+ AssignmentExpression: {
129
+ array: true,
130
+ object: false,
131
+ },
132
+ }, {
133
+ enforceForRenamedProperties: false,
134
+ }],
135
+
136
+ // disallow parseInt() in favor of binary, octal, and hexadecimal literals
137
+ // https://eslint.org/docs/rules/prefer-numeric-literals
138
+ 'prefer-numeric-literals': 'error',
139
+
140
+ // suggest using Reflect methods where applicable
141
+ // https://eslint.org/docs/rules/prefer-reflect
142
+ 'prefer-reflect': 'off',
143
+
144
+ // use rest parameters instead of arguments
145
+ // https://eslint.org/docs/rules/prefer-rest-params
146
+ 'prefer-rest-params': 'error',
147
+
148
+ // suggest using the spread syntax instead of .apply()
149
+ // https://eslint.org/docs/rules/prefer-spread
150
+ 'prefer-spread': 'error',
151
+
152
+ // suggest using template literals instead of string concatenation
153
+ // https://eslint.org/docs/rules/prefer-template
154
+ 'prefer-template': 'error',
155
+
156
+ // disallow generator functions that do not have yield
157
+ // https://eslint.org/docs/rules/require-yield
158
+ 'require-yield': 'error',
159
+
160
+ // enforce spacing between object rest-spread
161
+ // https://eslint.org/docs/rules/rest-spread-spacing
162
+ 'rest-spread-spacing': ['error', 'never'],
163
+
164
+ // import sorting
165
+ // https://eslint.org/docs/rules/sort-imports
166
+ 'sort-imports': ['off', {
167
+ ignoreCase: false,
168
+ ignoreDeclarationSort: false,
169
+ ignoreMemberSort: false,
170
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
171
+ }],
172
+
173
+ // require a Symbol description
174
+ // https://eslint.org/docs/rules/symbol-description
175
+ 'symbol-description': 'error',
176
+
177
+ // enforce usage of spacing in template strings
178
+ // https://eslint.org/docs/rules/template-curly-spacing
179
+ 'template-curly-spacing': 'error',
180
+
181
+ // enforce spacing around the * in yield* expressions
182
+ // https://eslint.org/docs/rules/yield-star-spacing
183
+ 'yield-star-spacing': ['error', 'after']
184
+ }
185
+ };
package/rules/node.js ADDED
@@ -0,0 +1,43 @@
1
+ export default {
2
+ env: {
3
+ node: true
4
+ },
5
+
6
+ rules: {
7
+ // enforce return after a callback
8
+ 'callback-return': 'off',
9
+
10
+ // require all requires be top-level
11
+ // https://eslint.org/docs/rules/global-require
12
+ 'global-require': 'error',
13
+
14
+ // enforces error handling in callbacks (node environment)
15
+ 'handle-callback-err': 'off',
16
+
17
+ // disallow use of the Buffer() constructor
18
+ // https://eslint.org/docs/rules/no-buffer-constructor
19
+ 'no-buffer-constructor': 'error',
20
+
21
+ // disallow mixing regular variable and require declarations
22
+ 'no-mixed-requires': ['off', false],
23
+
24
+ // disallow use of new operator with the require function
25
+ 'no-new-require': 'error',
26
+
27
+ // disallow string concatenation with __dirname and __filename
28
+ // https://eslint.org/docs/rules/no-path-concat
29
+ 'no-path-concat': 'error',
30
+
31
+ // disallow use of process.env
32
+ 'no-process-env': 'off',
33
+
34
+ // disallow process.exit()
35
+ 'no-process-exit': 'off',
36
+
37
+ // restrict usage of specified node modules
38
+ 'no-restricted-modules': 'off',
39
+
40
+ // disallow use of synchronous methods (off by default)
41
+ 'no-sync': 'off',
42
+ }
43
+ };
@@ -0,0 +1,6 @@
1
+ export default {
2
+ rules: {
3
+ // babel inserts `'use strict';` for us
4
+ strict: ['error', 'never']
5
+ }
6
+ };