You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/.eslintrc

116 lines
4.2 KiB
Plaintext

{
8 years ago
"extends": "airbnb-base",
"parserOptions": {
"sourceType": "script"
},
8 years ago
"rules": {
// === Configure rules for our style ===
// imports must be resolvable
"import/no-unresolved": "error",
// use single quotes,
// unless a different style allows avoiding escapes
"quotes": ["error", "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}],
// allow else-if return
"no-else-return": [ "error", { "allowElseIf": true } ],
// expressions split over multiple lines
// should break after the operator
"operator-linebreak": [ "error", "after" ],
// require arrow parens only when needed
// and whenever the body is a block
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
// what variables are errors in callbacks
8 years ago
"handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
// allow dangling commas in functions
// require them everywhere else
8 years ago
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "only-multiline"
8 years ago
}],
// we actually encourage `return await`
Async refactor in place (#7736) * feat: allow both callback&and await * feat: ignore async key * feat: callbackify and promisify in same file * Revert "feat: callbackify and promisify in same file" This reverts commit cea206a9b8e6d8295310074b18cc82a504487862. * feat: no need to store .callbackify * feat: change getTopics to async * feat: remove .async * fix: byScore * feat: rewrite topics/index and social with async/await * fix: rewrite topics/data.js fix issue with async.waterfall, only pass result if its not undefined * feat: add callbackify to redis/psql * feat: psql use await * fix: redis :volcano: * feat: less returns * feat: more await rewrite * fix: redis tests * feat: convert sortedSetAdd rewrite psql transaction to async/await * feat: :dog: * feat: test * feat: log client and query * feat: log bind * feat: more logs * feat: more logs * feat: check perform * feat: dont callbackify transaction * feat: remove logs * fix: main functions * feat: more logs * fix: increment * fix: rename * feat: remove cls * fix: remove console.log * feat: add deprecation message to .async usage * feat: update more dbal methods * fix: redis :voodoo: * feat: fix redis zrem, convert setObject * feat: upgrade getObject methods * fix: psql getObjectField * fix: redis tests * feat: getObjectKeys * feat: getObjectValues * feat: isObjectField * fix: add missing return * feat: delObjectField * feat: incrObjectField * fix: add missing await * feat: remove exposed helpers * feat: list methods * feat: flush/empty * feat: delete * fix: redis delete all * feat: get/set * feat: incr/rename * feat: type * feat: expire * feat: setAdd * feat: setRemove * feat: isSetMember * feat: getSetMembers * feat: setCount, setRemoveRandom * feat: zcard,zcount * feat: sortedSetRank * feat: isSortedSetMember * feat: zincrby * feat: sortedSetLex * feat: processSortedSet * fix: add mising await * feat: debug psql * fix: psql test * fix: test * fix: another test * fix: test fix * fix: psql tests * feat: remove logs * feat: user arrow func use builtin async promises * feat: topic bookmarks * feat: topic.delete * feat: topic.restore * feat: topics.purge * feat: merge * feat: suggested * feat: topics/user.js * feat: topics modules * feat: topics/follow * fix: deprecation msg * feat: fork * feat: topics/posts * feat: sorted/recent * feat: topic/teaser * feat: topics/tools * feat: topics/unread * feat: add back node versions disable deprecation notice wrap async controllers in try/catch * feat: use db directly * feat: promisify in place * fix: redis/psql * feat: deprecation message logs for psql * feat: more logs * feat: more logs * feat: logs again * feat: more logs * fix: call release * feat: restore travis, remove logs * fix: loops * feat: remove .async. usage
6 years ago
"no-return-await": "off",
// allow `while (true)`
"no-constant-condition": ["error", { "checkLoops": false }],
// allow ignoring an error with `catch`
8 years ago
"no-empty": ["error", { "allowEmptyCatch": true }],
// allow `3 + 5 - 1`, but not `3 * 5 - 1`
8 years ago
"no-mixed-operators": ["error", { "allowSamePrecedence": true }],
// require `'use strict';`
8 years ago
"strict": ["error", "global"],
// we actually use tabs for indentation
"indent": ["error", "tab", { "SwitchCase": 1 }],
"no-tabs": "off",
// we want `== null` to also handle undefined
"no-eq-null": "off",
// allow `for (..; i++)`
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
// allow using functions defined later
"no-use-before-define": ["error", "nofunc"],
// require consistent newlines before and after braces
// if contents are multiline
"object-curly-newline": ["error", { "consistent": true, "multiline": true }],
// require consistent linebreaks inline function parenthesis (arguments or params)
"function-paren-newline": ["error", "consistent"],
// only require const if all parts of destructuring can be const
"prefer-const": ["error", { "destructuring": "all" }],
// don't require destructuring for arrays or assignment
"prefer-destructuring": ["error", {
"VariableDeclarator": { "array": false, "object": true },
"AssignmentExpression": { "array": false, "object": false }
}],
// identical to airbnb rule, except for allowing for..of, because we want to use it
"no-restricted-syntax": [
"error",
{
"selector": "ForInStatement",
"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."
},
{
"selector": "LabeledStatement",
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
},
{
"selector": "WithStatement",
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
}
],
// allow lines of up to 120 characters
"max-len": ["error", { "code": 120, "tabWidth": 2, "ignoreUrls": true, "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreRegExpLiterals": true }],
// === Disable rules ===
// more liberal naming
"camelcase": "off",
"no-underscore-dangle": "off",
// don't require anonymous function names
"func-names": "off",
// allow console
"no-console": "off",
// allow new for side effects
// allow new with non-capitalized
"no-new": "off",
"new-cap": "off",
// allow shadowing variables (usually callbacks)
"no-shadow": "off",
// allow multiple empty lines in a row
"no-multiple-empty-lines": "off",
// allow not using object shorthand
"object-shorthand": "off",
8 years ago
// TODO
"consistent-return": "off",
"no-restricted-globals": "off",
"no-prototype-builtins": "off",
8 years ago
"import/no-extraneous-dependencies": "off",
"import/no-dynamic-require": "off",
"global-require": "off",
"no-param-reassign": "off",
"default-case": "off"
8 years ago
}
}