mirror of
https://github.com/searxng/searxng.git
synced 2025-07-08 18:54:37 -04:00
[mod] theme/simple: improve fmt/lint tech
This is one of various PR to refactor the simple theme internally. Replace eslint tool with Biome. I have been using this for quite some time, and it will help us to have more consistent and valid code without extending on other third party plugins. Removes unused dependencies.
This commit is contained in:
parent
0cbb4f74cc
commit
a947d5b3cf
2
Makefile
2
Makefile
@ -83,7 +83,7 @@ MANAGE += py.build py.clean
|
||||
MANAGE += pyenv pyenv.install pyenv.uninstall
|
||||
MANAGE += format.python
|
||||
MANAGE += test.yamllint test.pylint test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean test.themes test.types.dev test.types.ci
|
||||
MANAGE += themes.all themes.fix themes.test
|
||||
MANAGE += themes.all themes.simple themes.fix themes.lint themes.test
|
||||
MANAGE += static.build.commit static.build.drop static.build.restore
|
||||
MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs
|
||||
|
||||
|
1
client/simple/.gitignore
vendored
1
client/simple/.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
dist
|
||||
node_modules
|
||||
.stylelintcache
|
@ -1,17 +1,17 @@
|
||||
{
|
||||
"formatter": "unix",
|
||||
"$schema": "https://json.schemastore.org/stylelintrc.json",
|
||||
"plugins": ["stylelint-prettier"],
|
||||
"extends": ["stylelint-config-standard-less"],
|
||||
"rules": {
|
||||
"prettier/prettier": true,
|
||||
"at-rule-no-vendor-prefix": null,
|
||||
"declaration-empty-line-before": null,
|
||||
"no-invalid-position-at-import-rule": null,
|
||||
"prettier/prettier": true,
|
||||
"property-no-vendor-prefix": null,
|
||||
"selector-no-vendor-prefix": null,
|
||||
"selector-attribute-quotes": null,
|
||||
"shorthand-property-no-redundant-values": null,
|
||||
"at-rule-no-vendor-prefix": null,
|
||||
"selector-class-pattern": null,
|
||||
"selector-id-pattern": null,
|
||||
"selector-class-pattern": null
|
||||
"selector-no-vendor-prefix": null,
|
||||
"shorthand-property-no-redundant-values": null
|
||||
}
|
||||
}
|
||||
|
44
client/simple/biome.json
Normal file
44
client/simple/biome.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
|
||||
"files": {
|
||||
"includes": ["**", "!dist/**", "!node_modules/**"],
|
||||
"ignoreUnknown": true
|
||||
},
|
||||
"vcs": {
|
||||
"clientKind": "git",
|
||||
"enabled": false,
|
||||
"useIgnoreFile": true
|
||||
},
|
||||
"assist": {
|
||||
"enabled": true,
|
||||
"actions": {
|
||||
"recommended": true
|
||||
}
|
||||
},
|
||||
"formatter": {
|
||||
"bracketSameLine": false,
|
||||
"bracketSpacing": true,
|
||||
"enabled": true,
|
||||
"formatWithErrors": false,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineEnding": "lf",
|
||||
"lineWidth": 120
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"arrowParentheses": "always",
|
||||
"jsxQuoteStyle": "double",
|
||||
"quoteProperties": "asNeeded",
|
||||
"quoteStyle": "double",
|
||||
"semicolons": "always",
|
||||
"trailingCommas": "none"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import globals from "globals";
|
||||
import pluginJs from "@eslint/js";
|
||||
|
||||
|
||||
/** @type {import('eslint').Linter.Config[]} */
|
||||
export default [
|
||||
pluginJs.configs.recommended,
|
||||
|
||||
// global "ignores"
|
||||
// https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
|
||||
{
|
||||
ignores: ["node_modules/", "dist/"]
|
||||
},
|
||||
|
||||
{
|
||||
files: [
|
||||
"**/*.js",
|
||||
],
|
||||
linterOptions: {
|
||||
reportUnusedDisableDirectives: "error",
|
||||
// noInlineConfig: true
|
||||
},
|
||||
languageOptions: {
|
||||
sourceType: "module",
|
||||
globals: {
|
||||
...globals.browser,
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
indent: ["error", 2],
|
||||
},
|
||||
},
|
||||
|
||||
];
|
4287
client/simple/package-lock.json
generated
4287
client/simple/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,38 +1,36 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "simple",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "npm run build:icons && npm run build:vite",
|
||||
"build:icons": "node theme_icons.js",
|
||||
"build:vite": "vite build",
|
||||
"clean": "rm -Rf node_modules",
|
||||
"build": "node theme_icons.js && vite build",
|
||||
"fix": "eslint --fix && stylelint --fix strict 'src/**/*.{css,scss,sass,less,styl,vue,svelte}'",
|
||||
"icons.html": "node theme_icons.js"
|
||||
"fix": "npm run fix:stylelint && npm run fix:biome && npm run fix:package",
|
||||
"fix:biome": "biome check --write",
|
||||
"fix:package": "sort-package-json --quiet",
|
||||
"fix:stylelint": "stylelint --fix strict 'src/**/*.{scss,sass,less,styl}'",
|
||||
"lint": "npm run lint:biome",
|
||||
"lint:biome": "biome lint"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.29.0",
|
||||
"copy-webpack-plugin": "^13.0.0",
|
||||
"css-loader": "^7.1.2",
|
||||
"@biomejs/biome": "~2.0.6",
|
||||
"edge.js": "^6.2.1",
|
||||
"eslint": "^9.29.0",
|
||||
"filemanager-webpack-plugin": "^8.0.0",
|
||||
"globals": "^16.2.0",
|
||||
"ionicons": "^8.0.9",
|
||||
"leaflet": "^1.9.4",
|
||||
"less": "^4.3.0",
|
||||
"less-loader": "^12.3.0",
|
||||
"normalize.css": "^8.0.1",
|
||||
"sharp": "^0.34.2",
|
||||
"style-loader": "^4.0.0",
|
||||
"sort-package-json": "^3.0.0",
|
||||
"stylelint": "^16.21.0",
|
||||
"stylelint-config-standard": "^38.0.0",
|
||||
"stylelint-config-standard-less": "^3.0.1",
|
||||
"stylelint-prettier": "^5.0.3",
|
||||
"svgo": "^4.0.0",
|
||||
"swiped-events": "^1.2.0",
|
||||
"vite": "^6.3.5",
|
||||
"vite-plugin-static-copy": "^3.1.0",
|
||||
"vite-plugin-stylelint": "^6.0.0",
|
||||
"webpack": "^5.99.9",
|
||||
"webpack-cli": "^6.0.1"
|
||||
"vite-plugin-static-copy": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
import { resolve } from "node:path";
|
||||
import { defineConfig } from "vite";
|
||||
import stylelint from "vite-plugin-stylelint";
|
||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||
import { plg_svg2png } from "./tools/plg.js";
|
||||
import { plg_svg2svg } from "./tools/plg.js";
|
||||
@ -120,12 +119,6 @@ export default defineConfig({
|
||||
|
||||
plugins: [
|
||||
|
||||
stylelint({
|
||||
build: true,
|
||||
emitWarningAsError: true,
|
||||
fix: true,
|
||||
}),
|
||||
|
||||
// Leaflet
|
||||
|
||||
viteStaticCopy({
|
||||
|
@ -6,8 +6,8 @@ Development Quickstart
|
||||
|
||||
.. _npm: https://www.npmjs.com/
|
||||
.. _Node.js: https://nodejs.org/
|
||||
.. _eslint: https://eslint.org/
|
||||
.. _stylelint: https://stylelint.io/
|
||||
.. _Biome: https://biomejs.dev/
|
||||
.. _Stylelint: https://stylelint.io/
|
||||
|
||||
.. sidebar:: further read
|
||||
|
||||
@ -41,8 +41,8 @@ to our ":ref:`how to contribute`" guideline.
|
||||
|
||||
If you implement themes, you will need to setup a :ref:`Node.js environment
|
||||
<make node.env>`. Before you call *make run* (2.), you need to compile the
|
||||
modified styles and JavaScript: ``make node.clean themes.all``. If eslint_ or
|
||||
stylelint_ report some issues, try ``make themes.fix``.
|
||||
modified styles and JavaScript: ``make node.clean themes.all``. If Biome_
|
||||
or Stylelint_ reports issues, try ``make themes.fix``.
|
||||
|
||||
Alternatively you can also compile selective the theme you have modified,
|
||||
e.g. the *simple* theme.
|
||||
|
@ -1,6 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"eslint": "^9.17.0",
|
||||
"pyright": "^1.1.391"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -99,6 +99,7 @@ static.build.commit() {
|
||||
( set -e
|
||||
# fix & build the themes
|
||||
themes.fix
|
||||
themes.lint
|
||||
themes.all
|
||||
|
||||
# add build files
|
||||
|
@ -5,14 +5,23 @@ themes.help(){
|
||||
cat <<EOF
|
||||
themes.:
|
||||
all : test & build all themes
|
||||
simple : test & build simple theme
|
||||
lint : lint JS & CSS (LESS) files
|
||||
fix : fix JS & CSS (LESS) files
|
||||
test : test all themes
|
||||
fix : fix JS & CSS (LESS)
|
||||
EOF
|
||||
}
|
||||
|
||||
themes.all() {
|
||||
( set -e
|
||||
build_msg SIMPLE "theme: run build"
|
||||
vite.simple.build
|
||||
)
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
themes.simple() {
|
||||
( set -e
|
||||
build_msg SIMPLE "theme: run build (simple)"
|
||||
vite.simple.build
|
||||
)
|
||||
dump_return $?
|
||||
@ -20,12 +29,20 @@ themes.all() {
|
||||
|
||||
themes.fix() {
|
||||
( set -e
|
||||
build_msg SIMPLE "theme: fix"
|
||||
build_msg SIMPLE "theme: fix (all themes)"
|
||||
vite.simple.fix
|
||||
)
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
themes.lint() {
|
||||
( set -e
|
||||
build_msg SIMPLE "theme: lint (all themes)"
|
||||
vite.simple.lint
|
||||
)
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
themes.test() {
|
||||
( set -e
|
||||
# we run a build to test (in CI)
|
||||
|
@ -9,6 +9,8 @@ vite.help(){
|
||||
vite.: .. to be done ..
|
||||
simple.:
|
||||
build: build static files of the simple theme
|
||||
fix: run prettiers on simple theme
|
||||
lint: run linters on simple theme
|
||||
dev: start development server
|
||||
EOF
|
||||
}
|
||||
@ -36,8 +38,6 @@ vite.simple.build() {
|
||||
|
||||
pushd "${VITE_SIMPLE_THEME}"
|
||||
npm install
|
||||
npm run fix
|
||||
npm run icons.html
|
||||
npm run build
|
||||
popd &> /dev/null
|
||||
)
|
||||
@ -50,6 +50,13 @@ vite.simple.fix() {
|
||||
)
|
||||
}
|
||||
|
||||
vite.simple.lint() {
|
||||
( set -e
|
||||
node.env
|
||||
npm --prefix client/simple run lint
|
||||
)
|
||||
}
|
||||
|
||||
templates.simple.pygments() {
|
||||
build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
|
||||
pyenv.cmd python searxng_extra/update/update_pygments.py \
|
||||
|
Loading…
x
Reference in New Issue
Block a user