Skip to content

Commit

Permalink
internal/relui: format javascript and css
Browse files Browse the repository at this point in the history
This change adds eslint and stylelint to format javascript and css
files. The configuration is based on x/pkgsite and x/website, but
removing line-length rules and typescript plugins.

For golang/go#53382

Change-Id: I4bd8a9d23fb8d7369221f455095b26734981bc54
Reviewed-on: https://go-review.googlesource.com/c/build/+/412177
Run-TryBot: Alex Rakoczy <alex@golang.org>
Auto-Submit: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
toothrot authored and gopherbot committed Jun 16, 2022
1 parent ffa92a2 commit 66dff59
Show file tree
Hide file tree
Showing 11 changed files with 6,071 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
23 changes: 23 additions & 0 deletions cmd/relui/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root: true
extends: google
parserOptions:
ecmaVersion: 2018
rules:
require-jsdoc: 'off'
indent: 'off'
arrow-parens: 'off'
overrides:
- files:
- "*.js"
env:
browser: true
extends:
- eslint:recommended
- plugin:prettier/recommended
rules:
max-len: off
valid-jsdoc:
- error
- requireParamType: false
requireReturnType: false
requireReturn: false
4 changes: 4 additions & 0 deletions cmd/relui/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
arrowParens: avoid
singleQuote: true
bracketSpacing: false
quoteProps: consistent
12 changes: 12 additions & 0 deletions cmd/relui/.stylelintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends:
- stylelint-config-standard
- stylelint-prettier/recommended
plugins:
- stylelint-order
rules:
color-hex-case: lower
order/properties-alphabetical-order: true
unit-disallowed-list:
- 'px'
selector-class-pattern: '^[a-zA-Z\-]+$'
rule-empty-line-before: never
7 changes: 7 additions & 0 deletions cmd/relui/Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2022 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

FROM node:16.15.1-alpine3.16

WORKDIR /workspace/cmd/relui
26 changes: 26 additions & 0 deletions cmd/relui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ POSTGRES_TEST := psql --username=$(POSTGRES_USER) -c "SELECT 1;"

DEV_CFG := ${HOME}/.local/share/relui

MODULE_ROOT := "$(shell readlink -f ../../)"
NODE_IMAGE_VERSION := "node:16.15.1-bullseye"

.PHONY: dev
dev: postgres-dev docker
docker run --rm --name=relui-dev -v $(POSTGRES_RUN_DEV) -e PGUSER=$(POSTGRES_USER) -e PGDATABASE=relui-dev -p 8080:8080 $(DOCKER_TAG)
Expand Down Expand Up @@ -65,3 +68,26 @@ push-prod: docker-prod
deploy-prod: push-prod
go install golang.org/x/build/cmd/xb
xb --prod kubectl --namespace prod set image deployment/relui-deployment relui=$(IMAGE_PROD):$(VERSION)

node_modules/: package.json package-lock.json
docker run --rm \
--volume $(MODULE_ROOT):/workspace \
--workdir /workspace/cmd/relui \
--env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \
$(NODE_IMAGE_VERSION) \
npm install --no-update-notifier

.PHONY: lint
lint: node_modules/
docker run --rm \
--volume $(MODULE_ROOT):/workspace \
--workdir /workspace/cmd/relui \
--env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \
$(NODE_IMAGE_VERSION) \
npm --no-update-notifier run lint:js
docker run --rm \
--volume $(MODULE_ROOT):/workspace \
--workdir /workspace/cmd/relui \
--env NODE_OPTIONS="--experimental-vm-modules --no-warnings" \
$(NODE_IMAGE_VERSION) \
npm --no-update-notifier run lint:css
16 changes: 16 additions & 0 deletions cmd/relui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ Alternatively, using docker:
```bash
make test
```

## JS/CSS formatting and lint

This project uses eslint and stylelint to format JavaScript and CSS files.

To run:

```bash
npm run lint
```

Alternatively, using Docker:

```bash
make lint
```
Loading

0 comments on commit 66dff59

Please sign in to comment.