Skip to content

Commit 2b131a5

Browse files
Trottnodejs-github-bot
authored andcommittedSep 7, 2021
build: add YAML linting
PR-URL: nodejs#40007 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 77c81cb commit 2b131a5

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed
 

‎.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
!deps/**/.*
1010
!test/fixtures/**/.*
1111
!.clang-format
12+
!.cpplint
1213
!.editorconfig
1314
!.eslintignore
1415
!.eslintrc.js
16+
!.eslintrc.yaml
1517
!.flake8
1618
!.gitattributes
1719
!.github
1820
!.gitignore
1921
!.gitkeep
2022
!.mailmap
2123
!.nycrc
22-
!.eslintrc.yaml
23-
!.cpplint
24+
!.yamllint.yaml
2425

2526
# === Rules for root dir ===
2627
/core

‎.yamllint.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extends: relaxed
2+
3+
rules:
4+
line-length: disable
5+
6+
ignore: |
7+
/deps/
8+
node_modules/

‎Makefile

+22-3
Original file line numberDiff line numberDiff line change
@@ -1389,13 +1389,13 @@ cpplint: lint-cpp
13891389

13901390
.PHONY: lint-py-build
13911391
# python -m pip install flake8
1392-
# Try with '--system' is to overcome systems that blindly set '--user'
1392+
# Try with '--system' if it fails without; the system may have set '--user'
13931393
lint-py-build:
13941394
$(info Pip installing flake8 linter on $(shell $(PYTHON) --version)...)
13951395
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
13961396
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8
13971397

1398-
ifneq ("","$(wildcard tools/pip/site-packages)")
1398+
ifneq ("","$(wildcard tools/pip/site-packages/flake8)")
13991399
.PHONY: lint-py
14001400
# Lints the Python code with flake8.
14011401
# Flag the build if there are Python syntax errors or undefined names
@@ -1407,6 +1407,24 @@ lint-py:
14071407
$(warning Run 'make lint-py-build')
14081408
endif
14091409

1410+
.PHONY: lint-yaml-build
1411+
# python -m pip install yamllint
1412+
# Try with '--system' if it fails without; the system may have set '--user'
1413+
lint-yaml-build:
1414+
$(info Pip installing yamllint on $(shell $(PYTHON) --version)...)
1415+
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages yamllint || \
1416+
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages yamllint
1417+
1418+
.PHONY: lint-yaml
1419+
# Lints the YAML files with yamllint.
1420+
lint-yaml:
1421+
@if [ -d "tools/pip/site-packages/yamllint" ]; then \
1422+
PYTHONPATH=tools/pip $(PYTHON) -m yamllint .; \
1423+
else \
1424+
echo 'YAML linting with yamllint is not available'; \
1425+
echo "Run 'make lint-yaml-build'"; \
1426+
fi
1427+
14101428
.PHONY: lint
14111429
.PHONY: lint-ci
14121430
ifneq ("","$(wildcard tools/node_modules/eslint/)")
@@ -1416,11 +1434,12 @@ lint: ## Run JS, C++, MD and doc linters.
14161434
$(MAKE) lint-cpp || EXIT_STATUS=$$? ; \
14171435
$(MAKE) lint-addon-docs || EXIT_STATUS=$$? ; \
14181436
$(MAKE) lint-md || EXIT_STATUS=$$? ; \
1437+
$(MAKE) lint-yaml || EXIT_STATUS=$$? ; \
14191438
exit $$EXIT_STATUS
14201439
CONFLICT_RE=^>>>>>>> [[:xdigit:]]+|^<<<<<<< [[:alpha:]]+
14211440

14221441
# Related CI job: node-test-linter
1423-
lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs
1442+
lint-ci: lint-js-ci lint-cpp lint-py lint-md lint-addon-docs lint-yaml-build lint-yaml
14241443
@if ! ( grep -IEqrs "$(CONFLICT_RE)" --exclude="error-message.js" benchmark deps doc lib src test tools ) \
14251444
&& ! ( $(FIND) . -maxdepth 1 -type f | xargs grep -IEqs "$(CONFLICT_RE)" ); then \
14261445
exit 0 ; \

0 commit comments

Comments
 (0)
Please sign in to comment.