Pārlūkot izejas kodu

Add linter for package-lock.json `resolved`

pull/30719/head
silverwind pirms 1 mēnesi
vecāks
revīzija
04695bc990
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
3 mainītis faili ar 32 papildinājumiem un 3 dzēšanām
  1. 6
    2
      Makefile
  2. 25
    0
      tools/lint-lockfiles.js
  3. 1
    1
      tools/lint-templates-svg.js

+ 6
- 2
Makefile Parādīt failu

lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix lint-fix: lint-frontend-fix lint-backend-fix lint-spell-fix


.PHONY: lint-frontend .PHONY: lint-frontend
lint-frontend: lint-js lint-css
lint-frontend: lint-js lint-css lint-js-misc


.PHONY: lint-frontend-fix .PHONY: lint-frontend-fix
lint-frontend-fix: lint-js-fix lint-css-fix
lint-frontend-fix: lint-js-fix lint-css-fix lint-js-misc


.PHONY: lint-backend .PHONY: lint-backend
lint-backend: lint-go lint-go-vet lint-editorconfig lint-backend: lint-go lint-go-vet lint-editorconfig
lint-js-fix: node_modules lint-js-fix: node_modules
npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix


.PHONY: lint-js-misc
lint-js-misc: node_modules
node tools/lint-lockfiles.js

.PHONY: lint-css .PHONY: lint-css
lint-css: node_modules lint-css: node_modules
npx stylelint --color --max-warnings=0 $(STYLELINT_FILES) npx stylelint --color --max-warnings=0 $(STYLELINT_FILES)

+ 25
- 0
tools/lint-lockfiles.js Parādīt failu

#!/usr/bin/env node
import {readFileSync} from 'node:fs';
import {exit} from 'node:process';
import {relative} from 'node:path';
import {fileURLToPath} from 'node:url';

const files = [
'../package-lock.json',
'../web_src/fomantic/package-lock.json',
];

const rootPath = fileURLToPath(new URL('..', import.meta.url));
let hadErrors = false;

for (const file of files.map((file) => fileURLToPath(new URL(file, import.meta.url)))) {
const data = JSON.parse(readFileSync(file));
for (const [pkg, {resolved}] of Object.entries(data.packages)) {
if (resolved && !resolved.startsWith('https://registry.npmjs.org/')) {
console.info(`${relative(rootPath, file)}: Expected "resolved" on package ${pkg} to start with "https://registry.npmjs.org/"`);
hadErrors = true;
}
}
}

exit(hadErrors ? 1 : 0);

+ 1
- 1
tools/lint-templates-svg.js Parādīt failu

const content = readFileSync(file, 'utf8'); const content = readFileSync(file, 'utf8');
for (const [_, name] of content.matchAll(/svg ["'`]([^"'`]+)["'`]/g)) { for (const [_, name] of content.matchAll(/svg ["'`]([^"'`]+)["'`]/g)) {
if (!knownSvgs.has(name)) { if (!knownSvgs.has(name)) {
console.info(`SVG "${name}" not found, used in ${relative(rootPath, file)}`);
console.info(`${relative(rootPath, file)}: SVG "${name}" not found`);
hadErrors = true; hadErrors = true;
} }
} }

Notiek ielāde…
Atcelt
Saglabāt