style: eslint configuration
This commit is contained in:
parent
da1b2caaaf
commit
7d044df29d
115
.eslint
115
.eslint
@ -1,115 +0,0 @@
|
||||
{
|
||||
"extends": "airbnb-base",
|
||||
"parserOptions": {
|
||||
"sourceType": "script"
|
||||
},
|
||||
|
||||
"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
|
||||
"handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
|
||||
// allow dangling commas in functions
|
||||
// require them everywhere else
|
||||
"comma-dangle": ["error", {
|
||||
"arrays": "always-multiline",
|
||||
"objects": "always-multiline",
|
||||
"imports": "always-multiline",
|
||||
"exports": "always-multiline",
|
||||
"functions": "only-multiline"
|
||||
}],
|
||||
// we actually encourage `return await`
|
||||
"no-return-await": "off",
|
||||
// allow `while (true)`
|
||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||
// allow ignoring an error with `catch`
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
// allow `3 + 5 - 1`, but not `3 * 5 - 1`
|
||||
"no-mixed-operators": ["error", { "allowSamePrecedence": true }],
|
||||
// require `'use strict';`
|
||||
"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",
|
||||
|
||||
// TODO
|
||||
"consistent-return": "off",
|
||||
"no-restricted-globals": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"import/no-dynamic-require": "off",
|
||||
"global-require": "off",
|
||||
"no-param-reassign": "off",
|
||||
"default-case": "off"
|
||||
}
|
||||
}
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
32
lib/theme.js
32
lib/theme.js
@ -1,30 +1,30 @@
|
||||
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var Theme = module.exports;
|
||||
const Theme = module.exports;
|
||||
|
||||
Theme.defineWidgetAreas = async function(areas) {
|
||||
Theme.defineWidgetAreas = async function (areas) {
|
||||
areas = areas.concat([
|
||||
{
|
||||
'name': 'MOTD',
|
||||
'template': 'home.tpl',
|
||||
'location': 'motd'
|
||||
name: 'MOTD',
|
||||
template: 'home.tpl',
|
||||
location: 'motd',
|
||||
},
|
||||
{
|
||||
'name': 'Homepage Footer',
|
||||
'template': 'home.tpl',
|
||||
'location': 'footer'
|
||||
name: 'Homepage Footer',
|
||||
template: 'home.tpl',
|
||||
location: 'footer',
|
||||
},
|
||||
{
|
||||
'name': 'Category Sidebar',
|
||||
'template': 'category.tpl',
|
||||
'location': 'sidebar'
|
||||
name: 'Category Sidebar',
|
||||
template: 'category.tpl',
|
||||
location: 'sidebar',
|
||||
},
|
||||
{
|
||||
'name': 'Topic Footer',
|
||||
'template': 'topic.tpl',
|
||||
'location': 'footer'
|
||||
}
|
||||
name: 'Topic Footer',
|
||||
template: 'topic.tpl',
|
||||
location: 'footer',
|
||||
},
|
||||
]);
|
||||
return areas;
|
||||
};
|
||||
|
61
package.json
61
package.json
@ -1,32 +1,33 @@
|
||||
{
|
||||
"name": "nodebb-theme-quickstart",
|
||||
"version": "0.1.0",
|
||||
"description": "Enter a description here",
|
||||
"main": "theme.less",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npx lint-staged",
|
||||
"commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"bent": "^7.3.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "11.0.0",
|
||||
"@commitlint/config-angular": "11.0.0",
|
||||
"eslint": "7.18.0",
|
||||
"eslint-config-airbnb-base": "14.2.1",
|
||||
"eslint-plugin-import": "2.22.1",
|
||||
"husky": "5.0.9",
|
||||
"lint-staged": "10.5.4"
|
||||
}
|
||||
"name": "nodebb-theme-quickstart",
|
||||
"version": "0.1.0",
|
||||
"description": "Enter a description here",
|
||||
"main": "theme.less",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npx lint-staged",
|
||||
"commit-msg": "npx commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"bent": "^7.3.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "11.0.0",
|
||||
"@commitlint/config-angular": "11.0.0",
|
||||
"eslint": "8.x",
|
||||
"eslint-config-airbnb-base": "14.2.1",
|
||||
"eslint-config-nodebb": "0.1.1",
|
||||
"eslint-plugin-import": "2.x",
|
||||
"husky": "5.0.9",
|
||||
"lint-staged": "10.5.4"
|
||||
}
|
||||
}
|
||||
|
3
public/.eslintrc
Normal file
3
public/.eslintrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "nodebb/public"
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
Hey there!
|
||||
|
||||
@ -12,6 +14,6 @@
|
||||
});
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Your code goes here
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user