Merge pull request #538 from return42/eslint

SearXNG JavaScript Style Guide
This commit is contained in:
Markus Heiser 2021-12-14 08:07:22 +01:00 committed by GitHub
commit 4f22615259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 236 additions and 207 deletions

View File

@ -91,7 +91,7 @@
(json-mode (json-mode
. ((eval . (progn . ((eval . (progn
(setq-local js-indent-level 2) (setq-local js-indent-level 4)
(flycheck-checker . json-python-json))))) (flycheck-checker . json-python-json)))))
(js-mode (js-mode

View File

@ -89,7 +89,7 @@ MANAGE += py.build py.clean
MANAGE += pyenv pyenv.install pyenv.uninstall MANAGE += pyenv pyenv.install pyenv.uninstall
MANAGE += pypi.upload pypi.upload.test MANAGE += pypi.upload pypi.upload.test
MANAGE += test.yamllint test.pylint test.pep8 test.unit test.coverage test.robot test.clean MANAGE += test.yamllint test.pylint test.pep8 test.unit test.coverage test.robot test.clean
MANAGE += themes.all themes.oscar themes.simple pygments.less MANAGE += themes.all themes.oscar themes.simple themes.simple.test pygments.less
MANAGE += static.build.commit static.build.drop static.build.restore MANAGE += static.build.commit static.build.drop static.build.restore
MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs

11
manage
View File

@ -714,6 +714,17 @@ themes.simple() {
dump_return $? dump_return $?
} }
themes.simple.test() {
build_msg TEST "theme: simple"
if ! nvm.min_node "${NODE_MINIMUM_VERSION}"; then
info_msg "install Node.js by NVM"
nvm.nodejs
fi
npm --prefix searx/static/themes/simple install
npm --prefix searx/static/themes/simple run test
dump_return $?
}
PYLINT_FILES=() PYLINT_FILES=()
while IFS= read -r line; do while IFS= read -r line; do
PYLINT_FILES+=("$line") PYLINT_FILES+=("$line")

View File

@ -9,5 +9,21 @@
"ecmaVersion": 12 "ecmaVersion": 12
}, },
"rules": { "rules": {
"indent": ["error", 2],
"keyword-spacing": ["error", { "before": true, "after": true }],
"no-trailing-spaces": 2,
"space-before-function-paren": ["error", "always"],
"space-infix-ops": "error",
"comma-spacing": ["error", { "before": false, "after": true }],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"curly": ["error", "multi-line"],
"block-spacing": ["error", "always"],
"comma-spacing": ["error", { "before": false, "after": true }],
"dot-location": ["error", "property"],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"spaced-comment": ["error", "always", {
"line": { "markers": ["*package", "!", "/", ",", "="] },
"block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] }
}]
} }
} }

View File

@ -1,4 +1,4 @@
/*jshint esversion: 6 */ /* SPDX-License-Identifier: AGPL-3.0-or-later */
module.exports = function (grunt) { module.exports = function (grunt) {
@ -27,9 +27,11 @@ module.exports = function(grunt) {
eslint: { eslint: {
options: { options: {
overrideConfigFile: '.eslintrc.json', overrideConfigFile: '.eslintrc.json',
failOnError: false failOnError: true,
fix: grunt.option('fix')
}, },
target: [ target: [
'gruntfile.js',
'svg4web.svgo.js', 'svg4web.svgo.js',
'src/js/main/*.js', 'src/js/main/*.js',
'src/js/head/*.js', 'src/js/head/*.js',
@ -266,13 +268,12 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-image'); grunt.loadNpmTasks('grunt-image');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-stylelint'); grunt.loadNpmTasks('grunt-stylelint');
grunt.loadNpmTasks('grunt-eslint'); grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('test', ['jshint']); grunt.registerTask('test', ['eslint']);
grunt.registerTask('default', [ grunt.registerTask('default', [
'eslint', 'eslint',

View File

@ -4,7 +4,6 @@
"grunt": "~1.4.1", "grunt": "~1.4.1",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^4.0.0", "grunt-contrib-cssmin": "^4.0.0",
"grunt-contrib-jshint": "~3.1.1",
"grunt-contrib-less": "~3.0.0", "grunt-contrib-less": "~3.0.0",
"grunt-contrib-uglify": "~5.0.1", "grunt-contrib-uglify": "~5.0.1",
"grunt-xmlmin": "~0.1.8", "grunt-xmlmin": "~0.1.8",
@ -29,7 +28,9 @@
"scripts": { "scripts": {
"all": "npm install && grunt", "all": "npm install && grunt",
"build": "grunt", "build": "grunt",
"test": "grunt test",
"eslint": "grunt eslint", "eslint": "grunt eslint",
"eslint-fix": "grunt eslint --fix",
"watch": "grunt watch", "watch": "grunt watch",
"webfont": "grunt webfont", "webfont": "grunt webfont",
"clean": "rm -Rf node_modules package-lock.json ion.less", "clean": "rm -Rf node_modules package-lock.json ion.less",