Browse Source

add lint step to avoid non-npm dependencies in graph

fix azure pipeline windows script (set -e doesn't exist on windows)
tags/v4.29.6
Tobias Koppers 6 months ago
parent
commit
5dda69e615
5 changed files with 55 additions and 10 deletions
  1. 2
    1
      _SETUP.md
  2. 1
    4
      azure-pipelines.yml
  3. 3
    2
      package.json
  4. 27
    0
      test/Dependencies.lint.js
  5. 22
    3
      yarn.lock

+ 2
- 1
_SETUP.md View File

@@ -68,8 +68,9 @@ yarn pretty
This performs linting on:

* eslint (code-lint script)
* schema (schema-lint script)
* schema + dependencies (jest-lint script)
* types (type-lint script)
* format + generated files (special-lint script)

```bash
yarn lint

+ 1
- 4
azure-pipelines.yml View File

@@ -72,7 +72,7 @@ jobs:
set -e
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
yarn -s run code-lint --format junit > junit.xml
yarn schema-lint
yarn jest-lint
yarn type-lint
yarn special-lint
displayName: "Run linting"
@@ -205,18 +205,15 @@ jobs:
npm install --global yarn
displayName: "Install Yarn"
- script: |
set -e
node -v
yarn -v
displayName: "Print versions"
- script: |
set -e
yarn --frozen-lockfile
yarn link --frozen-lockfile || true
yarn link webpack --frozen-lockfile
displayName: "Install dependencies"
- script: |
set -e
yarn cover:init && yarn cover:integration --ci --maxWorkers=2 --reporters=jest-junit
displayName: "Run tests with coverage"
- task: PublishTestResults@2

+ 3
- 2
package.json View File

@@ -34,6 +34,7 @@
"@types/node": "^10.12.21",
"@types/tapable": "^1.0.1",
"@types/webpack-sources": "^0.1.4",
"@yarnpkg/lockfile": "^1.1.0",
"benchmark": "^2.1.1",
"bundle-loader": "~0.5.0",
"coffee-loader": "^0.9.0",
@@ -119,14 +120,14 @@
"build:examples": "cd examples && node buildAll.js",
"pretest": "yarn lint",
"prelint": "yarn setup",
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
"lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint",
"code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
"type-lint": "tsc --pretty",
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
"fix": "yarn code-lint --fix && yarn special-lint-fix",
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
"jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",
"cover:init": "rimraf coverage",

+ 27
- 0
test/Dependencies.lint.js View File

@@ -0,0 +1,27 @@
const fs = require("fs");
const path = require("path");
const lockfile = require("@yarnpkg/lockfile");

const file = fs.readFileSync(path.resolve(__dirname, "../yarn.lock"), "utf-8");
const result = lockfile.parse(file);

describe("Dependencies", () => {
it("should parse fine", () => {
expect(result.type).toBe("success");
});

if (result.type === "success") {
const content = result.object;
for (const dep of Object.keys(content)) {
describe(dep, () => {
const info = content[dep];
it("should resolve to a npm package", () => {
expect(info.resolved).toMatch(/^https:\/\/registry\.yarnpkg\.com\//);
});
it("should have a integrity hash", () => {
expect(info.integrity).toMatch(/^(sha1|sha512)-/);
});
});
}
}
});

+ 22
- 3
yarn.lock View File

@@ -383,6 +383,11 @@
resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==

abab@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
@@ -521,6 +526,11 @@ ansi-colors@^3.0.0:
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813"
integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==

ansi-escapes@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e"
integrity sha1-06ioOzGapneTZisT52HHkRQiMG4=

ansi-escapes@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30"
@@ -4096,7 +4106,8 @@ listr-silent-renderer@^1.1.1:

listr-update-renderer@^0.4.0:
version "0.4.0"
resolved "https://github.com/okonet/listr-update-renderer/tarball/upgrade-log-update#06073fa93166277607a7814f4e1f83960081414c"
resolved "https://registry.yarnpkg.com/listr-update-renderer/-/listr-update-renderer-0.4.0.tgz#344d980da2ca2e8b145ba305908f32ae3f4cc8a7"
integrity sha1-NE2YDaLKLosUW6MFkI8yrj9MyKc=
dependencies:
chalk "^1.1.3"
cli-truncate "^0.2.1"
@@ -4104,7 +4115,7 @@ listr-update-renderer@^0.4.0:
figures "^1.7.0"
indent-string "^3.0.0"
log-symbols "^1.0.2"
log-update "^2.3.0"
log-update "^1.0.2"
strip-ansi "^3.0.1"

listr-verbose-renderer@^0.4.0:
@@ -4203,6 +4214,14 @@ log-symbols@^2.2.0:
dependencies:
chalk "^2.0.1"

log-update@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-update/-/log-update-1.0.2.tgz#19929f64c4093d2d2e7075a1dad8af59c296b8d1"
integrity sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=
dependencies:
ansi-escapes "^1.0.0"
cli-cursor "^1.0.2"

log-update@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/log-update/-/log-update-2.3.0.tgz#88328fd7d1ce7938b29283746f0b1bc126b24708"
@@ -4839,7 +4858,7 @@ once@1.x, once@^1.3.0, once@^1.3.1, once@^1.4.0:

onetime@^1.0.0:
version "1.1.0"
resolved "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789"
integrity sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=

onetime@^2.0.0:

Loading…
Cancel
Save