Skip to content

Commit

Permalink
refactor(utl): convert the schema js to mjs (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij authored May 9, 2020
1 parent 40de0d8 commit 7af2aa1
Show file tree
Hide file tree
Showing 27 changed files with 584 additions and 573 deletions.
4 changes: 2 additions & 2 deletions .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
"attributes": { "fillcolor": "#cccccc" }
},
{
"criteria": { "source": "\\.schema\\.js$" },
"criteria": { "source": "\\.schema\\.mjs$" },
"attributes": {
"color": "darkgreen",
"fillcolor": "darkgreen",
Expand All @@ -255,7 +255,7 @@
"attributes": { "shape": "cylinder" }
},
{
"criteria": { "source": "\\-type\\.js$" },
"criteria": { "source": "\\-type\\.mjs$" },
"attributes": {
"fillcolor": "white",
"fontcolor": "darkgrey",
Expand Down
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
"max-lines": "off",
"max-lines-per-function": "off"
}
},
{
"files": ["utl/**/*.mjs"],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"node/no-unsupported-features/es-syntax": "off"
}
}
]
}
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ GENERATED_SOURCES=src/cli/init-config/config.js.template.js \
src/schema/configuration.schema.json \
src/schema/cruise-result.schema.json

SCHEMA_SOURCES=utl/schema/compound-exclude-type.js \
utl/schema/compound-donot-follow-type.js \
utl/schema/dependencies.js \
utl/schema/dependency-type.js \
utl/schema/module-system-type.js \
utl/schema/module-systems-type.js \
utl/schema/modules.js \
utl/schema/options-used.js \
utl/schema/options.js \
utl/schema/output-type.js \
utl/schema/reporter-options.js \
utl/schema/restrictions.js \
utl/schema/rule-set.js \
utl/schema/rule-summary.js \
utl/schema/severity-type.js \
utl/schema/summary.js
SCHEMA_SOURCES=utl/schema/compound-exclude-type.mjs \
utl/schema/compound-donot-follow-type.mjs \
utl/schema/dependencies.mjs \
utl/schema/dependency-type.mjs \
utl/schema/module-system-type.mjs \
utl/schema/module-systems-type.mjs \
utl/schema/modules.mjs \
utl/schema/options-used.mjs \
utl/schema/options.mjs \
utl/schema/output-type.mjs \
utl/schema/reporter-options.mjs \
utl/schema/restrictions.mjs \
utl/schema/rule-set.mjs \
utl/schema/rule-summary.mjs \
utl/schema/severity-type.mjs \
utl/schema/summary.mjs

.PHONY: help dev-build clean

Expand All @@ -47,8 +47,8 @@ help:
src/%.template.js: src/%.template.hbs
npx handlebars --commonjs handlebars/runtime -f $@ $<

src/%.schema.json: utl/%.schema.js $(SCHEMA_SOURCES)
$(NODE) ./utl/generate-schemas.utl.js
src/%.schema.json: utl/%.schema.mjs $(SCHEMA_SOURCES)
$(NODE) --experimental-modules ./utl/generate-schemas.utl.mjs

# "phony" targets
dev-build: $(GENERATED_SOURCES)
Expand Down
490 changes: 245 additions & 245 deletions docs/schema-overview.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
"depcruise:graph:fdp": "node ./bin/dependency-cruise.js --validate --include-only '^src' --output-type dot bin src | fdp -GK=0.1 -Gsplines=true -T svg > tmp_deps.svg",
"depcruise:report": "node ./bin/dependency-cruise.js --output-type err-html --validate -- src bin test configs types > dependency-violations.html",
"lint": "npm-run-all --parallel --aggregate-output lint:eslint lint:prettier:check lint:types",
"lint:eslint": "eslint bin/dependency-cruise.js src test configs utl --cache --cache-location .cache/eslint/",
"lint:eslint:fix": "eslint --fix bin src test configs utl --cache --cache-location .cache/eslint/",
"lint:eslint": "eslint bin/dependency-cruise.js src test configs utl utl/schema/\\*\\*/\\*.mjs --cache --cache-location .cache/eslint/",
"lint:eslint:fix": "eslint --fix bin src test configs utl utl/schema/\\*\\*/\\*.mjs --cache --cache-location .cache/eslint/",
"lint:fix": "npm-run-all lint:eslint:fix lint:prettier lint:types:fix",
"lint:prettier": "prettier --loglevel warn --write src/\\*\\*/\\*.{js,json} {utl,configs}/\\*\\*/\\*.js bin/\\* !**/*.template.js types/\\*.d.ts test/\\*\\*/\\*.{spec,utl}.js",
"lint:prettier:check": "prettier --loglevel warn --check src/\\*\\*/\\*.{js,json} {utl,configs}/\\*\\*/\\*.js bin/\\* !**/*.template.js types/\\*.d.ts test/\\*\\*/\\*.{spec,utl}.js",
"lint:prettier": "prettier --loglevel warn --write src/\\*\\*/\\*.{js,json} {utl,configs}/\\*\\*/\\*.js utl/\\*\\*/\\*.mjs bin/\\* !**/*.template.js types/\\*.d.ts test/\\*\\*/\\*.{spec,utl}.js",
"lint:prettier:check": "prettier --loglevel warn --check src/\\*\\*/\\*.{js,json} {utl,configs}/\\*\\*/\\*.js utl/\\*\\*/\\*.mjs bin/\\* !**/*.template.js types/\\*.d.ts test/\\*\\*/\\*.{spec,utl}.js",
"lint:types": "npm-run-all lint:types:tsc lint:types:tslint",
"lint:types:tsc": "tsc --noEmit --strict --types --noUnusedLocals --noUnusedParameters types/dependency-cruiser.d.ts",
"lint:types:tslint": "tslint types/dependency-cruiser.d.ts",
Expand Down Expand Up @@ -145,7 +145,7 @@
"chai-json-schema": "1.5.1",
"coffeescript": "2.5.1",
"eslint": "6.8.0",
"eslint-config-moving-meadow": "2.0.0",
"eslint-config-moving-meadow": "2.0.1",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-budapestian": "2.0.0",
"eslint-plugin-import": "2.20.2",
Expand Down
12 changes: 7 additions & 5 deletions utl/generate-schemas.utl.js → utl/generate-schemas.utl.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const fs = require("fs");
const path = require("path");
const prettier = require("prettier");
/* eslint-disable sort-imports */
import fs from "fs";
import path from "path";
import prettier from "prettier";
import configurationSchema from "./schema/configuration.schema.mjs";
import cruiseResultSchema from "./schema/cruise-result.schema.mjs";

const configurationSchema = require("./schema/configuration.schema.js");
const cruiseResultSchema = require("./schema/cruise-result.schema.js");
const __dirname = path.dirname(new URL(import.meta.url).pathname);

function jsonTheSchema(pJSONSchemaObject, pOutputFileName) {
fs.writeFileSync(
Expand Down
Loading

0 comments on commit 7af2aa1

Please sign in to comment.