eslint-config-nodebb 1.0.7 → 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/common.mjs +55 -0
- package/index.mjs +47 -0
- package/package.json +4 -3
- package/public.mjs +48 -0
- package/index.cjs +0 -95
- package/public.cjs +0 -78
package/common.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// rules common to both server and client
|
|
2
|
+
export default {
|
|
3
|
+
'@stylistic/js/semi': ['error', 'always'],
|
|
4
|
+
'@stylistic/js/no-multi-spaces': 'error',
|
|
5
|
+
'@stylistic/js/comma-dangle': ['error', {
|
|
6
|
+
arrays: 'always-multiline',
|
|
7
|
+
objects: 'always-multiline',
|
|
8
|
+
imports: 'always-multiline',
|
|
9
|
+
exports: 'always-multiline',
|
|
10
|
+
functions: 'only-multiline',
|
|
11
|
+
}],
|
|
12
|
+
'@stylistic/js/quotes': ['error', 'single', {
|
|
13
|
+
avoidEscape: true,
|
|
14
|
+
allowTemplateLiterals: true,
|
|
15
|
+
}],
|
|
16
|
+
'@stylistic/js/operator-linebreak': ['error', 'after'],
|
|
17
|
+
'@stylistic/js/no-mixed-operators': ['error', { allowSamePrecedence: true }],
|
|
18
|
+
|
|
19
|
+
'@stylistic/js/space-before-blocks': ['error', 'always'],
|
|
20
|
+
'@stylistic/js/space-infix-ops': 'error',
|
|
21
|
+
'@stylistic/js/space-in-parens': ['error', 'never'],
|
|
22
|
+
'@stylistic/js/indent': ['error', 'tab', { SwitchCase: 1 }],
|
|
23
|
+
'@stylistic/js/no-tabs': ['error', { allowIndentationTabs: true }],
|
|
24
|
+
'@stylistic/js/object-curly-newline': ['error', { consistent: true, multiline: true }],
|
|
25
|
+
|
|
26
|
+
'prefer-const': ['error', { destructuring: 'all' }],
|
|
27
|
+
'no-else-return': ['error', { allowElseIf: true }],
|
|
28
|
+
'no-unused-vars': ['error', { caughtErrors: 'none' }],
|
|
29
|
+
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
30
|
+
'no-irregular-whitespace': 'error',
|
|
31
|
+
'no-prototype-builtins': 'off',
|
|
32
|
+
|
|
33
|
+
'no-restricted-syntax': ['error',
|
|
34
|
+
{
|
|
35
|
+
selector: 'ForInStatement',
|
|
36
|
+
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
selector: 'LabeledStatement',
|
|
40
|
+
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
selector: 'WithStatement',
|
|
44
|
+
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
'max-len': ['error', {
|
|
48
|
+
code: 120,
|
|
49
|
+
tabWidth: 2,
|
|
50
|
+
ignoreUrls: true,
|
|
51
|
+
ignoreStrings: true,
|
|
52
|
+
ignoreTemplateLiterals: true,
|
|
53
|
+
ignoreRegExpLiterals: true,
|
|
54
|
+
}],
|
|
55
|
+
};
|
package/index.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import stylisticJs from '@stylistic/eslint-plugin-js'
|
|
4
|
+
import { defineConfig } from 'eslint/config';
|
|
5
|
+
import js from '@eslint/js';
|
|
6
|
+
import commonRules from './common.mjs';
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
{
|
|
10
|
+
plugins: {
|
|
11
|
+
js,
|
|
12
|
+
'@stylistic/js': stylisticJs,
|
|
13
|
+
},
|
|
14
|
+
extends: ['js/recommended'],
|
|
15
|
+
files: [
|
|
16
|
+
'*.js', 'src/**/*.js', 'lib/**/*.js', 'install/**/*.js', 'nodebb',
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
sourceType: 'commonjs',
|
|
21
|
+
globals: {
|
|
22
|
+
...globals.node,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
linterOptions: {
|
|
26
|
+
reportUnusedDisableDirectives: true,
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
...commonRules,
|
|
30
|
+
|
|
31
|
+
// === Project Style Rules ===
|
|
32
|
+
'@stylistic/js/arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
|
|
33
|
+
'@stylistic/js/function-paren-newline': ['error', 'consistent'],
|
|
34
|
+
|
|
35
|
+
// deprecated in eslint but still works
|
|
36
|
+
'handle-callback-err': ['error', '^(e$|(e|(.*(_e|E)))rr)'],
|
|
37
|
+
|
|
38
|
+
'strict': ['error', 'global'],
|
|
39
|
+
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
|
40
|
+
'no-use-before-define': ['error', 'nofunc'],
|
|
41
|
+
'prefer-destructuring': ['error', {
|
|
42
|
+
VariableDeclarator: { array: false, object: true },
|
|
43
|
+
AssignmentExpression: { array: false, object: false },
|
|
44
|
+
}],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-nodebb",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
"keywords": [],
|
|
10
10
|
"author": "",
|
|
11
11
|
"exports": {
|
|
12
|
-
".": "./index.
|
|
13
|
-
"./public": "./public.
|
|
12
|
+
".": "./index.mjs",
|
|
13
|
+
"./public": "./public.mjs"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@eslint/js": "^9.x",
|
|
17
|
+
"@stylistic/eslint-plugin-js": "4.2.0",
|
|
17
18
|
"eslint-plugin-import": "2.x"
|
|
18
19
|
},
|
|
19
20
|
"license": "ISC"
|
package/public.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import stylisticJs from '@stylistic/eslint-plugin-js';
|
|
4
|
+
import { defineConfig } from 'eslint/config';
|
|
5
|
+
import js from '@eslint/js';
|
|
6
|
+
import commonRules from './common.mjs';
|
|
7
|
+
|
|
8
|
+
export default defineConfig([
|
|
9
|
+
{
|
|
10
|
+
plugins: {
|
|
11
|
+
js,
|
|
12
|
+
'@stylistic/js': stylisticJs,
|
|
13
|
+
},
|
|
14
|
+
extends: ['js/recommended'],
|
|
15
|
+
files: [
|
|
16
|
+
'public/**/*.js', 'static/**/*.js'
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
globals: {
|
|
22
|
+
app: 'writable',
|
|
23
|
+
io: 'writable',
|
|
24
|
+
socket: 'writable',
|
|
25
|
+
ajaxify: 'writable',
|
|
26
|
+
config: 'writable',
|
|
27
|
+
utils: 'writable',
|
|
28
|
+
overrides: 'writable',
|
|
29
|
+
bootbox: 'writable',
|
|
30
|
+
Tinycon: 'writable',
|
|
31
|
+
Promise: 'writable',
|
|
32
|
+
ace: 'writable',
|
|
33
|
+
$: 'readonly',
|
|
34
|
+
jQuery: 'readonly',
|
|
35
|
+
define: 'readonly',
|
|
36
|
+
require: 'readonly',
|
|
37
|
+
module: 'readonly',
|
|
38
|
+
...globals.browser,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
linterOptions: {
|
|
42
|
+
reportUnusedDisableDirectives: true,
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
...commonRules,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
]);
|
package/index.cjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const globals = require('globals');
|
|
2
|
-
|
|
3
|
-
module.exports = [
|
|
4
|
-
{
|
|
5
|
-
files: [
|
|
6
|
-
'*.js', 'src/**/*.js', 'lib/**/*.js', 'install/**/*.js', 'nodebb',
|
|
7
|
-
],
|
|
8
|
-
languageOptions: {
|
|
9
|
-
ecmaVersion: 2020,
|
|
10
|
-
sourceType: 'commonjs',
|
|
11
|
-
globals: {
|
|
12
|
-
...globals.node,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
linterOptions: {
|
|
16
|
-
reportUnusedDisableDirectives: true,
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
// === Project Style Rules ===
|
|
20
|
-
'quotes': ['error', 'single', {
|
|
21
|
-
avoidEscape: true,
|
|
22
|
-
allowTemplateLiterals: true,
|
|
23
|
-
}],
|
|
24
|
-
'no-else-return': ['error', { allowElseIf: true }],
|
|
25
|
-
'no-unused-vars': ['error', { caughtErrors: 'none' }],
|
|
26
|
-
'operator-linebreak': ['error', 'after'],
|
|
27
|
-
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
|
|
28
|
-
'handle-callback-err': ['error', '^(e$|(e|(.*(_e|E)))rr)'],
|
|
29
|
-
'comma-dangle': ['error', {
|
|
30
|
-
arrays: 'always-multiline',
|
|
31
|
-
objects: 'always-multiline',
|
|
32
|
-
imports: 'always-multiline',
|
|
33
|
-
exports: 'always-multiline',
|
|
34
|
-
functions: 'only-multiline',
|
|
35
|
-
}],
|
|
36
|
-
'no-return-await': 'off',
|
|
37
|
-
'no-constant-condition': ['error', { checkLoops: false }],
|
|
38
|
-
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
39
|
-
'no-mixed-operators': ['error', { allowSamePrecedence: true }],
|
|
40
|
-
'strict': ['error', 'global'],
|
|
41
|
-
'indent': ['error', 'tab', { SwitchCase: 1 }],
|
|
42
|
-
'no-tabs': ['error', { allowIndentationTabs: true }],
|
|
43
|
-
'no-eq-null': 'off',
|
|
44
|
-
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
|
45
|
-
'no-use-before-define': ['error', 'nofunc'],
|
|
46
|
-
'object-curly-newline': ['error', { consistent: true, multiline: true }],
|
|
47
|
-
'function-paren-newline': ['error', 'consistent'],
|
|
48
|
-
'prefer-const': ['error', { destructuring: 'all' }],
|
|
49
|
-
'prefer-destructuring': ['error', {
|
|
50
|
-
VariableDeclarator: { array: false, object: true },
|
|
51
|
-
AssignmentExpression: { array: false, object: false },
|
|
52
|
-
}],
|
|
53
|
-
'no-restricted-syntax': [
|
|
54
|
-
'error',
|
|
55
|
-
{
|
|
56
|
-
selector: 'ForInStatement',
|
|
57
|
-
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
selector: 'LabeledStatement',
|
|
61
|
-
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
selector: 'WithStatement',
|
|
65
|
-
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
'max-len': ['error', {
|
|
69
|
-
code: 120,
|
|
70
|
-
tabWidth: 2,
|
|
71
|
-
ignoreUrls: true,
|
|
72
|
-
ignoreStrings: true,
|
|
73
|
-
ignoreTemplateLiterals: true,
|
|
74
|
-
ignoreRegExpLiterals: true,
|
|
75
|
-
}],
|
|
76
|
-
|
|
77
|
-
// === Disable Rules ===
|
|
78
|
-
'camelcase': 'off',
|
|
79
|
-
'no-underscore-dangle': 'off',
|
|
80
|
-
'func-names': 'off',
|
|
81
|
-
'no-console': 'off',
|
|
82
|
-
'no-new': 'off',
|
|
83
|
-
'new-cap': 'off',
|
|
84
|
-
'no-shadow': 'off',
|
|
85
|
-
'no-multiple-empty-lines': 'off',
|
|
86
|
-
'object-shorthand': 'off',
|
|
87
|
-
'consistent-return': 'off',
|
|
88
|
-
'no-restricted-globals': 'off',
|
|
89
|
-
'no-prototype-builtins': 'off',
|
|
90
|
-
'global-require': 'off',
|
|
91
|
-
'no-param-reassign': 'off',
|
|
92
|
-
'default-case': 'off',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
];
|
package/public.cjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const globals = require('globals');
|
|
2
|
-
|
|
3
|
-
module.exports = [
|
|
4
|
-
{
|
|
5
|
-
files: ['public/**/*.js', 'static/**/*.js'],
|
|
6
|
-
languageOptions: {
|
|
7
|
-
ecmaVersion: 2020,
|
|
8
|
-
sourceType: 'module',
|
|
9
|
-
globals: {
|
|
10
|
-
app: 'writable',
|
|
11
|
-
io: 'writable',
|
|
12
|
-
socket: 'writable',
|
|
13
|
-
ajaxify: 'writable',
|
|
14
|
-
config: 'writable',
|
|
15
|
-
utils: 'writable',
|
|
16
|
-
overrides: 'writable',
|
|
17
|
-
bootbox: 'writable',
|
|
18
|
-
Tinycon: 'writable',
|
|
19
|
-
Promise: 'writable',
|
|
20
|
-
ace: 'writable',
|
|
21
|
-
$: 'readonly',
|
|
22
|
-
jQuery: 'readonly',
|
|
23
|
-
define: 'readonly',
|
|
24
|
-
require: 'readonly',
|
|
25
|
-
module: 'readonly',
|
|
26
|
-
...globals.browser,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
linterOptions: {
|
|
30
|
-
reportUnusedDisableDirectives: true,
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
'comma-dangle': ['error', {
|
|
34
|
-
arrays: 'always-multiline',
|
|
35
|
-
objects: 'always-multiline',
|
|
36
|
-
imports: 'always-multiline',
|
|
37
|
-
exports: 'always-multiline',
|
|
38
|
-
functions: 'never',
|
|
39
|
-
}],
|
|
40
|
-
'block-scoped-var': 'off',
|
|
41
|
-
'no-dupe-class-members': 'off',
|
|
42
|
-
'prefer-object-spread': 'off',
|
|
43
|
-
'prefer-reflect': 'off',
|
|
44
|
-
strict: 'off',
|
|
45
|
-
|
|
46
|
-
// ES6 rules
|
|
47
|
-
'no-prototype-builtins': 'off',
|
|
48
|
-
'prefer-rest-params': 'off',
|
|
49
|
-
'prefer-spread': 'off',
|
|
50
|
-
'prefer-arrow-callback': 'off',
|
|
51
|
-
'prefer-template': 'off',
|
|
52
|
-
'no-var': 'off',
|
|
53
|
-
'object-shorthand': 'off',
|
|
54
|
-
'vars-on-top': 'off',
|
|
55
|
-
'prefer-destructuring': 'off',
|
|
56
|
-
|
|
57
|
-
// Custom restrictions
|
|
58
|
-
'no-restricted-syntax': [
|
|
59
|
-
'error',
|
|
60
|
-
{
|
|
61
|
-
selector: 'ForOfStatement',
|
|
62
|
-
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
selector: 'LabeledStatement',
|
|
66
|
-
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
selector: 'WithStatement',
|
|
70
|
-
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
ignores: [
|
|
75
|
-
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
];
|