Skip to content

Commit

Permalink
refactor(*): standardize on kebab case file names (sverweij#267)
Browse files Browse the repository at this point in the history
- also introduce some rules from the eslint-plugin-unicorn along with the one that enforces kebab-case file names
  • Loading branch information
sverweij authored Feb 23, 2020
1 parent d4e01e0 commit ee5dd3d
Show file tree
Hide file tree
Showing 241 changed files with 3,729 additions and 3,594 deletions.
22 changes: 11 additions & 11 deletions .dependency-cruiser.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@
"severity": "error",
"from": {
"path": "(^src/cli/)",
"pathNot": "^(src/cli/compileConfig/index\\.js)$"
"pathNot": "^(src/cli/compile-config/index\\.js)$"
},
"to": {
"pathNot": "^src/main/|^node_modules|^fs$|^path$|$1|^package.json$"
}
},
{
"name": "cli-to-main-only-warn",
"comment": "This cli module depends on something not in the public interface - which means it either doesn't belong in cli, or the main public interface needs to be expanded (this warn-only rule is a temporary exception for the compileConfig depending on the resolver).",
"severity": "warn",
"from": { "path": "^(src/cli/compile-config/index\\.js)$" },
"to": {
"pathNot": "$1|^src/(cli|main)|^node_modules|^(fs|path|package.json)$"
}
},
{
"name": "report-stays-in-report",
"comment": "This reporting module depends directly on a non-reporting one that is not a utility. That is odd as reporting modules should only read dependency cruiser output json.",
Expand All @@ -45,15 +54,6 @@
"exoticallyRequired": false
}
},
{
"name": "cli-to-main-only-warn",
"comment": "This cli module depends on something not in the public interface - which means it either doesn't belong in cli, or the main public interface needs to be expanded (this warn-only rule is a temporary exception for the compileConfig depending on the resolver).",
"severity": "warn",
"from": { "path": "^(src/cli/compileConfig/index\\.js)$" },
"to": {
"pathNot": "$1|^src/(cli|main)|^node_modules|^(fs|path|package.json)$"
}
},
{
"name": "bin-to-cli-only",
"comment": "This module in the bin/ folder depends on something not in the cli interface. This means it either contains code that doesn't belong in bin/, or the thing it depends upon should be put in the cli interface. ",
Expand All @@ -66,7 +66,7 @@
"comment": "This module depends on a the node 'fs' module, and it resides in a spot where that is not allowed.",
"severity": "error",
"from": {
"pathNot": "^src/(extract/parse|extract/resolve|extract/gatherInitialSources\\.js|cli)|^test|^utl"
"pathNot": "^src/(extract/parse|extract/resolve|extract/gather-initial-sources\\.js|cli)|^test|^utl"
},
"to": { "path": "^fs$" }
},
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.project
.settings/*
.vscode
.idea

# metrics results
.nyc_output
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.SUFFIXES: .js .css .html
NODE=node
RM=rm -f
GENERATED_SOURCES=src/cli/initConfig/config.js.template.js \
GENERATED_SOURCES=src/cli/init-config/config.js.template.js \
src/report/csv/csv.template.js \
src/report/dot/dot.template.js \
src/report/html/html.template.js \
Expand Down
6 changes: 3 additions & 3 deletions bin/depcruise-fmt.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const validateNodeEnv = require("../src/cli/validateNodeEnv");
const validateNodeEnv = require("../src/cli/validate-node-env");

function formatError(pError) {
process.stderr.write(pError.message);
Expand Down Expand Up @@ -42,6 +42,6 @@ try {
} else {
program.help();
}
} catch (e) {
formatError(e);
} catch (pError) {
formatError(pError);
}
6 changes: 3 additions & 3 deletions bin/dependency-cruise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const validateNodeEnv = require("../src/cli/validateNodeEnv");
const validateNodeEnv = require("../src/cli/validate-node-env");

try {
validateNodeEnv();
Expand Down Expand Up @@ -90,7 +90,7 @@ try {
} else {
program.help();
}
} catch (e) {
process.stderr.write(e.message);
} catch (pError) {
process.stderr.write(pError.message);
process.exitCode = 1;
}
52 changes: 50 additions & 2 deletions configs/eslint-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["security", "mocha", "node", "import"],
"plugins": ["security", "mocha", "node", "import", "unicorn"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
Expand Down Expand Up @@ -281,6 +281,54 @@
"import/no-named-export": "error",
"import/no-anonymous-default-export": "error",
"import/group-exports": "off",
"dynamic-import-chunkname": "off"
"dynamic-import-chunkname": "off",

"unicorn/better-regex": "off",
"unicorn/catch-error-name": ["error", { "name": "pError" }],
"unicorn/consistent-function-scoping": "off",
"unicorn/custom-error-definition": "off",
"unicorn/error-message": "error",
"unicorn/escape-case": "error",
"unicorn/expiring-todo-comments": "error",
"unicorn/explicit-length-check": "error",
"unicorn/filename-case": ["error", { "case": "kebabCase" }],
"unicorn/import-index": "off",
"unicorn/new-for-builtins": "off", // conflicts with security/detect-non-literal-regexp, apparently
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/no-array-instanceof": "error",
"unicorn/no-console-spaces": "error",
"unicorn/no-fn-reference-in-iterator": "off",
"unicorn/no-for-loop": "error",
"unicorn/no-hex-escape": "error",
"unicorn/no-keyword-prefix": "off",
"no-nested-ternary": "off",
"unicorn/no-nested-ternary": "error",
"unicorn/no-new-buffer": "error",
"unicorn/no-process-exit": "error",
"unicorn/no-unreadable-array-destructuring": "error",
"unicorn/no-unsafe-regex": "error",
"unicorn/no-unused-properties": "off",
"unicorn/no-zero-fractions": "error",
"unicorn/number-literal-case": "error",
"unicorn/prefer-add-event-listener": "error",
"unicorn/prefer-dataset": "error",
"unicorn/prefer-event-key": "error",
"unicorn/prefer-flat-map": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-modern-dom-apis": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/prefer-node-append": "error",
"unicorn/prefer-node-remove": "error",
"unicorn/prefer-query-selector": "error",
"unicorn/prefer-reflect-apply": "error",
"unicorn/prefer-replace-all": "off",
"unicorn/prefer-spread": "error",
"unicorn/prefer-starts-ends-with": "error",
"unicorn/prefer-string-slice": "error",
"unicorn/prefer-text-content": "error",
"unicorn/prefer-trim-start-end": "error",
"unicorn/prefer-type-error": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/throw-new-error": "error"
}
}
Loading

0 comments on commit ee5dd3d

Please sign in to comment.