eslint-config-nodebb 0.2.0 → 1.0.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/lib.js CHANGED
@@ -1,115 +1,93 @@
1
- module.exports = {
2
- "extends": "airbnb-base",
3
- "parserOptions": {
4
- "sourceType": "script"
5
- },
6
-
7
- "rules": {
8
- // === Configure rules for our style ===
9
- // imports must be resolvable
10
- "import/no-unresolved": "error",
11
- // use single quotes,
12
- // unless a different style allows avoiding escapes
13
- "quotes": ["error", "single", {
14
- "avoidEscape": true,
15
- "allowTemplateLiterals": true
1
+ export default [
2
+ {
3
+ files: ['**/*.js'],
4
+ languageOptions: {
5
+ ecmaVersion: 2020,
6
+ sourceType: 'script', // equivalent to your v8 "parserOptions.sourceType"
7
+ globals: {
8
+ // Node.js globals are implied, no need to redefine unless custom ones are used
9
+ }
10
+ },
11
+ linterOptions: {
12
+ reportUnusedDisableDirectives: true
13
+ },
14
+ rules: {
15
+ // === Project Style Rules ===
16
+ 'import/no-unresolved': 'error',
17
+ 'quotes': ['error', 'single', {
18
+ avoidEscape: true,
19
+ allowTemplateLiterals: true
16
20
  }],
17
- // allow else-if return
18
- "no-else-return": [ "error", { "allowElseIf": true } ],
19
- // expressions split over multiple lines
20
- // should break after the operator
21
- "operator-linebreak": [ "error", "after" ],
22
- // require arrow parens only when needed
23
- // and whenever the body is a block
24
- "arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
25
- // what variables are errors in callbacks
26
- "handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
27
- // allow dangling commas in functions
28
- // require them everywhere else
29
- "comma-dangle": ["error", {
30
- "arrays": "always-multiline",
31
- "objects": "always-multiline",
32
- "imports": "always-multiline",
33
- "exports": "always-multiline",
34
- "functions": "only-multiline"
21
+ 'no-else-return': ['error', { allowElseIf: true }],
22
+ 'operator-linebreak': ['error', 'after'],
23
+ 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
24
+ 'handle-callback-err': ['error', '^(e$|(e|(.*(_e|E)))rr)'],
25
+ 'comma-dangle': ['error', {
26
+ arrays: 'always-multiline',
27
+ objects: 'always-multiline',
28
+ imports: 'always-multiline',
29
+ exports: 'always-multiline',
30
+ functions: 'only-multiline'
35
31
  }],
36
- // we actually encourage `return await`
37
- "no-return-await": "off",
38
- // allow `while (true)`
39
- "no-constant-condition": ["error", { "checkLoops": false }],
40
- // allow ignoring an error with `catch`
41
- "no-empty": ["error", { "allowEmptyCatch": true }],
42
- // allow `3 + 5 - 1`, but not `3 * 5 - 1`
43
- "no-mixed-operators": ["error", { "allowSamePrecedence": true }],
44
- // require `'use strict';`
45
- "strict": ["error", "global"],
46
- // we actually use tabs for indentation
47
- "indent": ["error", "tab", { "SwitchCase": 1 }],
48
- "no-tabs": ["error", { allowIndentationTabs: true }],
49
- // we want `== null` to also handle undefined
50
- "no-eq-null": "off",
51
- // allow `for (..; i++)`
52
- "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
53
- // allow using functions defined later
54
- "no-use-before-define": ["error", "nofunc"],
55
- // require consistent newlines before and after braces
56
- // if contents are multiline
57
- "object-curly-newline": ["error", { "consistent": true, "multiline": true }],
58
- // require consistent linebreaks inline function parenthesis (arguments or params)
59
- "function-paren-newline": ["error", "consistent"],
60
- // only require const if all parts of destructuring can be const
61
- "prefer-const": ["error", { "destructuring": "all" }],
62
- // don't require destructuring for arrays or assignment
63
- "prefer-destructuring": ["error", {
64
- "VariableDeclarator": { "array": false, "object": true },
65
- "AssignmentExpression": { "array": false, "object": false }
32
+ 'no-return-await': 'off',
33
+ 'no-constant-condition': ['error', { checkLoops: false }],
34
+ 'no-empty': ['error', { allowEmptyCatch: true }],
35
+ 'no-mixed-operators': ['error', { allowSamePrecedence: true }],
36
+ 'strict': ['error', 'global'],
37
+ 'indent': ['error', 'tab', { SwitchCase: 1 }],
38
+ 'no-tabs': ['error', { allowIndentationTabs: true }],
39
+ 'no-eq-null': 'off',
40
+ 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
41
+ 'no-use-before-define': ['error', 'nofunc'],
42
+ 'object-curly-newline': ['error', { consistent: true, multiline: true }],
43
+ 'function-paren-newline': ['error', 'consistent'],
44
+ 'prefer-const': ['error', { destructuring: 'all' }],
45
+ 'prefer-destructuring': ['error', {
46
+ VariableDeclarator: { array: false, object: true },
47
+ AssignmentExpression: { array: false, object: false }
66
48
  }],
67
- // identical to airbnb rule, except for allowing for..of, because we want to use it
68
- "no-restricted-syntax": [
69
- "error",
70
- {
71
- "selector": "ForInStatement",
72
- "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."
73
- },
74
- {
75
- "selector": "LabeledStatement",
76
- "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
77
- },
78
- {
79
- "selector": "WithStatement",
80
- "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
81
- }
49
+ 'no-restricted-syntax': [
50
+ 'error',
51
+ {
52
+ selector: 'ForInStatement',
53
+ 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.'
54
+ },
55
+ {
56
+ selector: 'LabeledStatement',
57
+ message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
58
+ },
59
+ {
60
+ selector: 'WithStatement',
61
+ message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
62
+ }
82
63
  ],
83
- // allow lines of up to 120 characters
84
- "max-len": ["error", { "code": 120, "tabWidth": 2, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreRegExpLiterals": true }],
85
-
86
- // === Disable rules ===
87
- // more liberal naming
88
- "camelcase": "off",
89
- "no-underscore-dangle": "off",
90
- // don't require anonymous function names
91
- "func-names": "off",
92
- // allow console
93
- "no-console": "off",
94
- // allow new for side effects
95
- // allow new with non-capitalized
96
- "no-new": "off",
97
- "new-cap": "off",
98
- // allow shadowing variables (usually callbacks)
99
- "no-shadow": "off",
100
- // allow multiple empty lines in a row
101
- "no-multiple-empty-lines": "off",
102
- // allow not using object shorthand
103
- "object-shorthand": "off",
64
+ 'max-len': ['error', {
65
+ code: 120,
66
+ tabWidth: 2,
67
+ ignoreUrls: true,
68
+ ignoreStrings: true,
69
+ ignoreTemplateLiterals: true,
70
+ ignoreRegExpLiterals: true
71
+ }],
104
72
 
105
- // TODO
106
- "consistent-return": "off",
107
- "no-restricted-globals": "off",
108
- "no-prototype-builtins": "off",
109
- "import/no-extraneous-dependencies": "off",
110
- "import/no-dynamic-require": "off",
111
- "global-require": "off",
112
- "no-param-reassign": "off",
113
- "default-case": "off"
73
+ // === Disable Rules ===
74
+ 'camelcase': 'off',
75
+ 'no-underscore-dangle': 'off',
76
+ 'func-names': 'off',
77
+ 'no-console': 'off',
78
+ 'no-new': 'off',
79
+ 'new-cap': 'off',
80
+ 'no-shadow': 'off',
81
+ 'no-multiple-empty-lines': 'off',
82
+ 'object-shorthand': 'off',
83
+ 'consistent-return': 'off',
84
+ 'no-restricted-globals': 'off',
85
+ 'no-prototype-builtins': 'off',
86
+ 'import/no-extraneous-dependencies': 'off',
87
+ 'import/no-dynamic-require': 'off',
88
+ 'global-require': 'off',
89
+ 'no-param-reassign': 'off',
90
+ 'default-case': 'off'
91
+ }
114
92
  }
115
- }
93
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-nodebb",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,12 +8,12 @@
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "",
11
- "dependencies": {
12
- "eslint-config-airbnb-base": "15.0.0"
11
+ "exports": {
12
+ ".": "./index.js",
13
+ "./public": "./public.js"
13
14
  },
14
15
  "peerDependencies": {
15
- "eslint": "7.x || 8.x",
16
- "eslint-plugin-import": "2.x"
16
+ "eslint": "^9.x"
17
17
  },
18
18
  "license": "ISC"
19
19
  }
package/public.js CHANGED
@@ -1,83 +1,68 @@
1
- module.exports = {
2
- "globals": {
3
- "app": true,
4
- "io": true,
5
- "socket": true,
6
- "ajaxify": true,
7
- "config": true,
8
- "utils": true,
9
- "overrides": true,
10
- "componentHandler": true,
11
- "bootbox": true,
12
- "Tinycon": true,
13
- "Promise": true,
14
- "navigator": true,
15
- "ace": true
16
- },
17
- "env": {
18
- "jquery": true,
19
- "amd": true,
20
- "browser": true,
21
- "es6": true
22
- },
23
- "rules": {
24
- "comma-dangle": ["error", {
25
- "arrays": "always-multiline",
26
- "objects": "always-multiline",
27
- "imports": "always-multiline",
28
- "exports": "always-multiline",
29
- "functions": "never"
1
+ export default [
2
+ {
3
+ files: ['**/*.js'],
4
+ languageOptions: {
5
+ ecmaVersion: 2020,
6
+ sourceType: 'module',
7
+ globals: {
8
+ app: 'writable',
9
+ io: 'writable',
10
+ socket: 'writable',
11
+ ajaxify: 'writable',
12
+ config: 'writable',
13
+ utils: 'writable',
14
+ overrides: 'writable',
15
+ componentHandler: 'writable',
16
+ bootbox: 'writable',
17
+ Tinycon: 'writable',
18
+ Promise: 'writable',
19
+ navigator: 'writable',
20
+ ace: 'writable'
21
+ }
22
+ },
23
+ linterOptions: {
24
+ reportUnusedDisableDirectives: true
25
+ },
26
+ rules: {
27
+ 'comma-dangle': ['error', {
28
+ arrays: 'always-multiline',
29
+ objects: 'always-multiline',
30
+ imports: 'always-multiline',
31
+ exports: 'always-multiline',
32
+ functions: 'never'
30
33
  }],
31
- "block-scoped-var": "off",
32
- "no-dupe-class-members": "off",
33
- "prefer-object-spread": "off",
34
- "prefer-reflect": "off",
34
+ 'block-scoped-var': 'off',
35
+ 'no-dupe-class-members': 'off',
36
+ 'prefer-object-spread': 'off',
37
+ 'prefer-reflect': 'off',
38
+ strict: 'off',
39
+
40
+ // ES6 rules
41
+ 'prefer-rest-params': 'off',
42
+ 'prefer-spread': 'off',
43
+ 'prefer-arrow-callback': 'off',
44
+ 'prefer-template': 'off',
45
+ 'no-var': 'off',
46
+ 'object-shorthand': 'off',
47
+ 'vars-on-top': 'off',
48
+ 'prefer-destructuring': 'off',
35
49
 
36
- // ES6
37
- "prefer-rest-params": "off",
38
- "prefer-spread": "off",
39
- "prefer-arrow-callback": "off",
40
- "prefer-template": "off",
41
- "no-var": "off",
42
- "object-shorthand": "off",
43
- "vars-on-top": "off",
44
- "prefer-destructuring": "off",
45
- // identical to airbnb rule
46
- // except for allowing for..in, because for..of is unavailable on some clients
47
- "no-restricted-syntax": [
48
- "error",
49
- {
50
- "selector": "ForOfStatement",
51
- "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."
52
- },
53
- {
54
- "selector": "LabeledStatement",
55
- "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
56
- },
57
- {
58
- "selector": "WithStatement",
59
- "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
60
- }
50
+ // Custom restrictions
51
+ 'no-restricted-syntax': [
52
+ 'error',
53
+ {
54
+ selector: 'ForOfStatement',
55
+ 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.'
56
+ },
57
+ {
58
+ selector: 'LabeledStatement',
59
+ message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
60
+ },
61
+ {
62
+ selector: 'WithStatement',
63
+ message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
64
+ }
61
65
  ]
62
- },
63
- "parserOptions": {
64
- "ecmaVersion": 2020,
65
- "sourceType": "module",
66
- "ecmaFeatures": {
67
- "classes": false,
68
- "defaultParams": false,
69
- "blockBindings": false,
70
- "forOf": false,
71
- "generators": false,
72
- "globalReturn": false,
73
- "jsx": false,
74
- "objectLiteralComputedProperties": false,
75
- "objectLiteralDuplicateProperties": false,
76
- "objectLiteralShorthandMethods": false,
77
- "objectLiteralShorthandProperties": false,
78
- "impliedStrict": false,
79
- "restParams": false,
80
- "superInFunctions": false
81
- }
66
+ }
82
67
  }
83
- }
68
+ ];
File without changes