Add eslint workflow action and CONTRIBUTING.md that says to lint first #66

Merged
thepaperpilot merged 6 commits from thepaperpilot/Profectus:feat/enforce-eslint into main 2024-03-06 04:45:20 +00:00
12 changed files with 59 additions and 11 deletions
Showing only changes of commit 143b0773e7 - Show all commits

View file

@ -19,3 +19,4 @@ jobs:
- run: npm ci - run: npm ci
- run: npm run build --if-present - run: npm run build --if-present
- run: npm test - run: npm test
- run: npm run lint

View file

@ -19,3 +19,4 @@ jobs:
- run: npm ci - run: npm ci
- run: npm run build --if-present - run: npm run build --if-present
- run: npm test - run: npm test
- run: npm run lint

View file

@ -1,7 +1,7 @@
{ {
"vitest.commandLine": "npx vitest", "vitest.commandLine": "npx vitest",
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": "explicit"
}, },
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"git.ignoreLimitWarning": true, "git.ignoreLimitWarning": true,

31
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,31 @@
# Contributing to Profectus
Thank you for considering contributing to Profectus! We appreciate your interest in improving our project. Please take a moment to review the following guidelines to streamline the contribution process.
## Getting Started
For detailed instructions on setting up local development environment, please refer to the [Setup Guide](https://moddingtree.com/guide/getting-started/setup).
## Contributing
Make sure to open your PR on Incremental Social - the GitHub repo is just a mirror!
### Code Review
All PRs must be reviewed and approved by at least one of the project maintainers before merging. Please be patient during the review process and be open to feedback.
### Testing
Ensure that your changes pass all existing tests and, if applicable, add new tests to cover the changes you've made. Run `npm run test` to run all the tests.
## Code Style
escapee marked this conversation as resolved
Review

Is this supposed to be a subcategory of Contributing (###) or a separate category (##)?

Is this supposed to be a subcategory of Contributing (###) or a separate category (##)?
We use ESLint and Prettier to enforce consistent code style throughout the project. Before submitting a PR, run `npm run lint:fix` to automatically fix any linting issues.
## Issue Reporting
If you encounter a bug or have a suggestion for improvement, please open an issue on Incremental Social. Provide as much detail as possible, including an example repo or steps to reproduce the issue if applicable.
## License
By contributing to Profectus, you agree that your contributions will be licensed under the project's [LICENSE](./LICENSE).

View file

@ -9,7 +9,9 @@
"preview": "vite preview", "preview": "vite preview",
"test": "vitest run", "test": "vitest run",
"testw": "vitest", "testw": "vitest",
"serve": "vite preview --host" "serve": "vite preview --host",
"lint": "eslint src --max-warnings 0",
"lint:fix": "eslint --fix --max-warnings 0 src"
}, },
"dependencies": { "dependencies": {
"@fontsource/material-icons": "^4.5.4", "@fontsource/material-icons": "^4.5.4",

View file

@ -19,7 +19,7 @@ import Error from "components/Error.vue";
import { jsx } from "features/feature"; import { jsx } from "features/feature";
import state from "game/state"; import state from "game/state";
import { coerceComponent, render } from "util/vue"; import { coerceComponent, render } from "util/vue";
import { CSSProperties, watch } from "vue"; import { CSSProperties } from "vue";
import { computed, toRef, unref } from "vue"; import { computed, toRef, unref } from "vue";
import Game from "./components/Game.vue"; import Game from "./components/Game.vue";
import GameOverScreen from "./components/GameOverScreen.vue"; import GameOverScreen from "./components/GameOverScreen.vue";

View file

@ -31,7 +31,7 @@ import { coerceComponent, isCoercableComponent, render } from "util/vue";
import { computed, Ref, ref, unref } from "vue"; import { computed, Ref, ref, unref } from "vue";
import { BarOptions, createBar, GenericBar } from "./bars/bar"; import { BarOptions, createBar, GenericBar } from "./bars/bar";
import { ClickableOptions } from "./clickables/clickable"; import { ClickableOptions } from "./clickables/clickable";
import { Decorator, GenericDecorator } from "./decorators/common"; import { GenericDecorator } from "./decorators/common";
/** A symbol used to identify {@link Action} features. */ /** A symbol used to identify {@link Action} features. */
export const ActionType = Symbol("Action"); export const ActionType = Symbol("Action");

View file

@ -1,6 +1,6 @@
import type { CoercableComponent, GenericComponent, Replace, StyleValue } from "features/feature"; import type { CoercableComponent, GenericComponent, Replace, StyleValue } from "features/feature";
import { Component, GatherProps, setDefault } from "features/feature"; import { Component, GatherProps, setDefault } from "features/feature";
import { deletePersistent, Persistent, persistent } from "game/persistence"; import { persistent } from "game/persistence";
import { Direction } from "util/common"; import { Direction } from "util/common";
import type { import type {
Computable, Computable,

View file

@ -1,4 +1,4 @@
import { Decorator, GenericDecorator } from "features/decorators/common"; import { GenericDecorator } from "features/decorators/common";
import type { import type {
CoercableComponent, CoercableComponent,
GenericComponent, GenericComponent,

View file

@ -552,7 +552,9 @@ export function tetrate(
export function invertTetrate( export function invertTetrate(
value: DecimalSource, value: DecimalSource,
base: FormulaSource, base: FormulaSource,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
height: FormulaSource, height: FormulaSource,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
payload: FormulaSource payload: FormulaSource
) { ) {
if (hasVariable(base)) { if (hasVariable(base)) {
@ -576,6 +578,7 @@ export function invertIteratedExp(
value: DecimalSource, value: DecimalSource,
lhs: FormulaSource, lhs: FormulaSource,
height: FormulaSource, height: FormulaSource,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
payload: FormulaSource payload: FormulaSource
) { ) {
if (hasVariable(lhs)) { if (hasVariable(lhs)) {
@ -626,6 +629,7 @@ export function invertLayeradd(
value: DecimalSource, value: DecimalSource,
lhs: FormulaSource, lhs: FormulaSource,
diff: FormulaSource, diff: FormulaSource,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
base: FormulaSource base: FormulaSource
) { ) {
if (hasVariable(lhs)) { if (hasVariable(lhs)) {

View file

@ -296,10 +296,17 @@ export function createSequentialModifier<
: undefined, : undefined,
getFormula: modifiers.every(m => m.getFormula != null) getFormula: modifiers.every(m => m.getFormula != null)
? (gain: FormulaSource) => ? (gain: FormulaSource) =>
modifiers modifiers.reduce(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion (acc, curr) =>
.reduce((acc, curr) => Formula.if(acc, curr.enabled ?? true, Formula.if(
acc => curr.getFormula!(acc), acc => acc), gain) acc,
curr.enabled ?? true,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
acc => curr.getFormula!(acc),
acc => acc
),
gain
)
: undefined, : undefined,
enabled: modifiers.some(m => m.enabled != null) enabled: modifiers.some(m => m.enabled != null)
? computed(() => modifiers.filter(m => unref(m.enabled) !== false).length > 0) ? computed(() => modifiers.filter(m => unref(m.enabled) !== false).length > 0)

View file

@ -222,7 +222,9 @@ export function createCostRequirement<T extends CostRequirementOptions>(
Decimal.gte( Decimal.gte(
req.resource.value, req.resource.value,
unref(req.cost as ProcessedComputable<DecimalSource>) unref(req.cost as ProcessedComputable<DecimalSource>)
) ? 1 : 0 )
? 1
: 0
); );
} }