Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add commit-lint #47

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run commitlint ${1}
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run prettier:check
npm run pre-commit
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.min.css
3 changes: 3 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["stylelint-config-standard"]
}
65 changes: 65 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* This commitlint config file extends the conventional configuration
* and adds the following customizations:
*
* - Ignores commit messages that start with "Merge"
* - Allows the following commit types:
* - build
* - chore
* - ci
* - docs
* - feat
* - fix
* - perf
* - refactor
* - revert
* - style
* - test
* - Merge
*
* Please see the commitlint documentation for more information on how to use
* this configuration file:
* https://commitlint.js.org/reference/rules.html
*
*/
const RuleConfigSeverity = {
Disabled: 0,
Warning: 1,
Error: 2,
};

module.exports = {
ignores: [(message) => message.startsWith("Merge")],
rules: {
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
],
],
"body-case": [RuleConfigSeverity.Disabled, "always"],
"body-leading-blank": [RuleConfigSeverity.Warning, "always"],
"body-max-line-length": [RuleConfigSeverity.Disabled, "always"],
"footer-leading-blank": [RuleConfigSeverity.Warning, "always"],
"footer-max-line-length": [RuleConfigSeverity.Disabled, "always"],
"header-max-length": [RuleConfigSeverity.Disabled, "always"],
"header-trim": [RuleConfigSeverity.Error, "always"],
"scope-case": [RuleConfigSeverity.Error, "always", "lower-case"],
"subject-case": [RuleConfigSeverity.Disabled, "always"],
"subject-empty": [RuleConfigSeverity.Error, "never"],
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."],
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"],
"type-empty": [RuleConfigSeverity.Error, "never"],
},
};
167 changes: 167 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import eslintConfigPrettier from "eslint-config-prettier";
import globals from "globals";
import html from "eslint-plugin-html";
import json from "eslint-plugin-json";
import pluginJs from "@eslint/js";
import stylisticJs from "@stylistic/eslint-plugin-js";

export default [
pluginJs.configs.recommended,
eslintConfigPrettier,
{
files: ["**/*.js", "**/*.html", "**/*.twig"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "commonjs",
globals: {
...globals.browser,
...globals.commonjs,
...globals.node,
$: "readonly",
$id: "readonly",
arch: "readonly",
checkMount: "readonly",
dialog: "readonly",
formatBytes: "readonly",
formatEta: "readonly",
hash_alg: "readonly",
id: "readonly",
ipcRenderer: "readonly",
loadInclude: "readonly",
path: "readonly",
platform: "readonly",
remote: "readonly",
shell: "readonly",
sidenoderHome: "readonly",
version: "readonly",
win: "readonly",
},
},
plugins: {
html,
"@stylistic/js": stylisticJs,
},
rules: {
"@stylistic/js/brace-style": [
"error",
"1tbs",
{ allowSingleLine: false },
],
"@stylistic/js/indent": [
"error",
2,
{
ignoredNodes: ["TemplateLiteral"],
SwitchCase: 1,
},
],
"@stylistic/js/no-mixed-spaces-and-tabs": ["error"],
"@stylistic/js/semi": ["error", "always"],
"constructor-super": ["error"],
curly: ["error", "all"],
eqeqeq: ["error", "always"],
"for-direction": ["error"],
"getter-return": ["error"],
"no-async-promise-executor": ["error"],
"no-case-declarations": ["error"],
"no-class-assign": ["error"],
"no-compare-neg-zero": ["error"],
"no-cond-assign": ["error"],
"no-const-assign": ["error"],
"no-constant-condition": ["error"],
"no-control-regex": ["error"],
"no-debugger": ["error"],
"no-delete-var": ["error"],
"no-dupe-args": ["error"],
"no-dupe-class-members": ["error"],
"no-dupe-else-if": ["error"],
"no-dupe-keys": ["error"],
"no-duplicate-case": ["error"],
"no-else-return": ["error"],
"no-empty": ["error"],
"no-empty-character-class": ["error"],
"no-empty-pattern": ["error"],
"no-ex-assign": ["error"],
"no-extra-boolean-cast": ["off"],
"no-fallthrough": ["error"],
"no-func-assign": ["error"],
"no-global-assign": ["error"],
"no-import-assign": ["error"],
"no-inner-declarations": ["off"],
"no-invalid-regexp": ["error"],
"no-irregular-whitespace": ["error"],
"no-loss-of-precision": ["error"],
"no-misleading-character-class": ["error"],
"no-nonoctal-decimal-escape": ["error"],
"no-obj-calls": ["error"],
"no-octal": ["error"],
"no-prototype-builtins": ["error"],
"no-redeclare": ["error"],
"no-regex-spaces": ["error"],
"no-self-assign": ["error"],
"no-setter-return": ["error"],
"no-shadow-restricted-names": ["error"],
"no-sparse-arrays": ["error"],
"no-this-before-super": ["error"],
"no-undef": ["error"],
"no-unexpected-multiline": ["error"],
"no-unreachable": ["error"],
"no-unsafe-finally": ["error"],
"no-unsafe-negation": ["error"],
"no-unsafe-optional-chaining": ["error"],
"no-unused-labels": ["error"],
"no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
},
],
"no-use-before-define": [
"error",
{
functions: false,
classes: true,
variables: true,
allowNamedExports: true,
},
],
"no-useless-backreference": ["error"],
"no-useless-catch": ["error"],
"no-useless-escape": ["error"],
"no-var": ["error"],
"no-with": ["error"],
"prefer-const": [
"error",
{
destructuring: "all",
},
],
"prefer-regex-literals": ["error"],
"prefer-template": ["error"],
"require-yield": ["error"],
"use-isnan": ["error"],
"valid-typeof": ["error"],
},
},
{
files: ["**/*.mjs"],
languageOptions: {
sourceType: "module",
},
},
{
files: ["**/*.json"],
plugins: {
json,
},
processor: json.processors[".json"],
rules: {
...json.configs.recommended.rules,
},
},
{
ignores: ["**/node_modules/**", "**/*.min.js", "**/modernizr.custom.js"],
},
];
Loading