Skip to content

Commit

Permalink
feat(commitlint): commitlint config
Browse files Browse the repository at this point in the history
added custom commitlint config package
  • Loading branch information
Jake Lauer authored and Jake Lauer committed May 26, 2024
1 parent 33fedeb commit 1aa3a8f
Show file tree
Hide file tree
Showing 66 changed files with 3,255 additions and 3,180 deletions.
76 changes: 1 addition & 75 deletions .commitlintrc
Original file line number Diff line number Diff line change
@@ -1,76 +1,2 @@
extends:
- '@commitlint/config-conventional'
prompt:
messages:
skip: ':skip'
max: 'upper %d chars'
min: '%d chars at least'
emptyWarning: 'can not be empty'
upperLimitWarning: 'over limit'
lowerLimitWarning: 'below limit'
questions:
type:
description: "Select the type of change that you're committing"
enum:
feat:
description: 'A new feature'
title: 'Features'
emoji: '✨'
fix:
description: 'A bug fix'
title: 'Bug Fixes'
emoji: '🐛'
docs:
description: 'Documentation only changes'
title: 'Documentation'
emoji: '📚'
style:
description: 'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)'
title: 'Styles'
emoji: '💎'
refactor:
description: 'A code change that neither fixes a bug nor adds a feature'
title: 'Code Refactoring'
emoji: '📦'
perf:
description: 'A code change that improves performance'
title: 'Performance Improvements'
emoji: '🚀'
test:
description: 'Adding missing tests or correcting existing tests'
title: 'Tests'
emoji: '🚨'
build:
description: 'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)'
title: 'Builds'
emoji: '🛠'
ci:
description: 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)'
title: 'Continuous Integrations'
emoji: '⚙️'
chore:
description: "Other changes that don't modify src or test files"
title: 'Chores'
emoji: '♻️'
revert:
description: 'Reverts a previous commit'
title: 'Reverts'
emoji: '🗑'
scope:
description: 'What is the scope of this change (e.g. component or file name)'
subject:
description: 'Write a short, imperative tense description of the change'
body:
description: 'Provide a longer description of the change'
isBreaking:
description: 'Are there any breaking changes?'
breakingBody:
description: 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself'
breaking:
description: 'Describe the breaking changes'
isIssueAffected:
description: 'Does this change affect any open issues?'
issuesBody:
description: 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
issues:
description: 'Add issue references (e.g. "fix #123", "re #123".)'
- '@theseus/commitlint-config'
5 changes: 2 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
parser: "@typescript-eslint/parser",
ignorePatterns: ["*.js"],
parserOptions: {
project: ["./tsconfig.json", "./.examples/tic-tac-toe/tsconfig.json", "./packages/eslint-plugin-theseus/tsconfig.json"],
project: ["./**/tsconfig.json", "./.examples/**/tsconfig.json"],
ecmaVersion: 2018,
sourceType: "module",
tsconfigRootDir: "./",
Expand All @@ -23,7 +23,7 @@ module.exports = {
},
plugins: ["unused-imports"],
rules: {
indent: ["error", "tab"],
"indent": ["error", "tab", { "SwitchCase": 1 }],
quotes: [2, "double", { avoidEscape: true }],
"unused-imports/no-unused-imports": "error",
"no-async-promise-executor": "off",
Expand All @@ -45,7 +45,6 @@ module.exports = {
],
"semi": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"indent": ["error", 4, { "SwitchCase": 1 }],
"array-bracket-spacing": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"max-len": ["error", { "code": 120, "ignoreUrls": true, "ignoreTemplateLiterals": true, "ignoreStrings": true }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GameBoardEvolver } from "./evolvers/GameBoardEvolver";
import { GameMetaEvolver } from "./evolvers/GameMetaEvolver";

export const GameEvolverComplex = EvolverComplex.create<GameState>().withEvolvers({
GameTurnEvolver,
GameBoardEvolver,
GameMetaEvolver,
GameTurnEvolver,
GameBoardEvolver,
GameMetaEvolver,
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Evolver } from "theseus-js";
import type { GameState, MarkType } from "../../state/GameState";

export const { GameBoardEvolver } = Evolver.create("GameBoardEvolver", { noun: "gameState" })
.toEvolve<GameState>()
.withMutators({
/**
.toEvolve<GameState>()
.withMutators({
/**
* Set the mark at the given coordinates.
*/
setMark: ({ mutableGameState }, coords: [number, number], mark: MarkType): GameState =>
{
const [row, col] = coords;
mutableGameState.board[row][col] = mark;
return mutableGameState;
},
});
setMark: ({ mutableGameState }, coords: [number, number], mark: MarkType): GameState =>
{
const [row, col] = coords;
mutableGameState.board[row][col] = mark;
return mutableGameState;
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import { Evolver } from "theseus-js";
import type { GameState, MarkType } from "../../state/GameState";

export const { GameMetaEvolver } = Evolver.create("GameMetaEvolver", { noun: "gameState" })
.toEvolve<GameState>()
.withMutators({
/**
.toEvolve<GameState>()
.withMutators({
/**
* Update the last player to make a move.
*/
updateLastPlayer: ({ mutableGameState }, mark: MarkType): GameState =>
{
mutableGameState.lastPlayer = mark;
return mutableGameState;
},
/**
updateLastPlayer: ({ mutableGameState }, mark: MarkType): GameState =>
{
mutableGameState.lastPlayer = mark;
return mutableGameState;
},
/**
* Update the last played coordinates.
*/
updateLastPlayedCoords: ({ mutableGameState }, coords: [number, number]): GameState =>
{
mutableGameState.lastPlayedCoords = coords;
return mutableGameState;
},
/**
updateLastPlayedCoords: ({ mutableGameState }, coords: [number, number]): GameState =>
{
mutableGameState.lastPlayedCoords = coords;
return mutableGameState;
},
/**
* Iterate the turn count.
*/
iterateTurnCount: ({ mutableGameState }): GameState =>
{
mutableGameState.turns++;
return mutableGameState;
},
});
iterateTurnCount: ({ mutableGameState }): GameState =>
{
mutableGameState.turns++;
return mutableGameState;
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,52 @@ import { GameMetaEvolver } from "./GameMetaEvolver";
const log = getTheseusLogger("GameTurnEvolver");

export const { GameTurnEvolver } = Evolver.create("GameTurnEvolver", { noun: "gameState" })
.toEvolve<GameState>()
.withMutators({
/**
.toEvolve<GameState>()
.withMutators({
/**
* Set the winner of the game.
*/
setWinner: ({ mutableGameState }, reason: "stalemate" | "winner") =>
{
log.major(`Game over! ${reason}`);
mutableGameState.winner = reason === "winner" ? mutableGameState.lastPlayer : "stalemate";
return mutableGameState;
},
/**
setWinner: ({ mutableGameState }, reason: "stalemate" | "winner") =>
{
log.major(`Game over! ${reason}`);
mutableGameState.winner = reason === "winner" ? mutableGameState.lastPlayer : "stalemate";
return mutableGameState;
},
/**
* Take the next turn at a random available square.
*/
nextTurn: ({ mutableGameState }): GameState =>
{
const { turns, lastPlayer } = mutableGameState;
log.major(`Taking turn #${turns}`);

const { getRandomAvailableCoords, getSquare } = GameBoardRefinery(mutableGameState);

// Determine the mark for the next player
const mark = lastPlayer === "X" ? "O" : "X";
const coords = getRandomAvailableCoords();
if (!coords)
{
return GameTurnEvolver.mutate(mutableGameState).via.setWinner("stalemate");
}

// Check if the square is available
const isAvailable = !getSquare(coords);
if (!isAvailable)
{
throw new Error(`Square at ${coords} is already taken`);
}

// Set the mark on the board
GameBoardEvolver.mutate(mutableGameState)
.via.setMark(coords, mark);

// Update the game metadata
GameMetaEvolver.evolve(mutableGameState)
.via.iterateTurnCount()
.and.updateLastPlayer(mark)
.and.updateLastPlayedCoords(coords);

return mutableGameState;
},
});
nextTurn: ({ mutableGameState }): GameState =>
{
const { turns, lastPlayer } = mutableGameState;
log.major(`Taking turn #${turns}`);

const { getRandomAvailableCoords, getSquare } = GameBoardRefinery(mutableGameState);

// Determine the mark for the next player
const mark = lastPlayer === "X" ? "O" : "X";
const coords = getRandomAvailableCoords();
if (!coords)
{
return GameTurnEvolver.mutate(mutableGameState).via.setWinner("stalemate");
}

// Check if the square is available
const isAvailable = !getSquare(coords);
if (!isAvailable)
{
throw new Error(`Square at ${coords} is already taken`);
}

// Set the mark on the board
GameBoardEvolver.mutate(mutableGameState)
.via.setMark(coords, mark);

// Update the game metadata
GameMetaEvolver.evolve(mutableGameState)
.via.iterateTurnCount()
.and.updateLastPlayer(mark)
.and.updateLastPlayedCoords(coords);

return mutableGameState;
},
});
4 changes: 2 additions & 2 deletions .examples/tic-tac-toe/src/game-ship/game-ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { initialGameState } from "./state/GameState";
import { GameEvolverComplex } from "./evolve/GameEvolverComplex";

export const GameShip = theseus(initialGameState).maintainWith({
evolvers: GameEvolverComplex,
refineries: GameRefineryComplex,
evolvers: GameEvolverComplex,
refineries: GameRefineryComplex,
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { GameBoardRefinery } from "./refineries/GameBoardRefinery";
import { GameOutcomeRefinery } from "./refineries/GameOutcomeRefinery";

export const GameRefineryComplex = RefineryComplex.create<GameState>().withRefineries({
GameBoardRefinery,
GameOutcomeRefinery,
GameBoardRefinery,
GameOutcomeRefinery,
});
Loading

0 comments on commit 1aa3a8f

Please sign in to comment.