Skip to content
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Auto detect text files and perform LF normalization
* text=auto

pre-commit eol=lf
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
push:
pull_request:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'

- name: Install dependencies
run: npm install

- parallel:
- name: ESLint
run: npm run lint:js

- name: Stylelint
run: npm run lint:css
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/.vite/
/.coverage/

.eslintcache
.stylelintcache

# Log files
*.log
npm-debug.log*
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ If you encounter a bug, graphical glitch, or something isn't working as expected

**Create a Pull Request:** Do you have a feature you would like added, or a task that you would like added that could benefit other Tenno? Fork the repository, and create a pull request!

### Coding Style

This project uses [ESLint](https://eslint.org/) and [Stylelint](https://stylelint.io/) to enforce a consistent coding style.
A GitHub workflow will check your code automatically when you push changes or create a pull request.
You can also run the checks locally with `npm run lint`, and [a git pre-commit hook is provided](./pre-commit) that you can install.
Extensions may also be available for your editor.

### AI Policy

You must disclose any use of AI that went in to preparing your pull request by **both**:

1. Marking the appropriate box in the pull request template, *and*
Expand Down
134 changes: 134 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import js from "@eslint/js";
import globals from "globals";
import json from "@eslint/json";
import css from "@eslint/css";
import { defineConfig } from "eslint/config";
import stylistic from "@stylistic/eslint-plugin";

export default defineConfig([
{ ignores: [".coverage/**/*"] },
{
linterOptions: {
reportUnusedInlineConfigs: "warn",
},
},
{
files: ["sources/**/*.{js,mjs,cjs}", "*.config.*js"],
plugins: { js },
languageOptions: {
globals: globals.browser,
},
extends: [
"js/recommended",
stylistic.configs.customize({
indent: 4,
semi: true,
quotes: "double",
jsx: false,
arrowParens: true,
quoteProps: "consistent",
}),
],
rules: {
// "important" stuff
"curly": ["error", "all"],
"eqeqeq": ["error", "always"],
"no-var": "error",
"prefer-const": "error",
"radix": "error",
// niche stuff
"array-callback-return": "error",
"no-duplicate-imports": "error",
"no-self-compare": "error",
"no-template-curly-in-string": "warn",
"no-unreachable-loop": "error",
"no-use-before-define": ["error", "nofunc"],
"block-scoped-var": "error",
"consistent-return": "error",
"default-param-last": "error",
"dot-notation": "warn",
"func-style": ["error", "declaration"],
"no-empty-function": "error",
"no-extend-native": "error",
"no-labels": "error",
"no-implicit-coercion": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-new-wrappers": "error",
"no-object-constructor": "error",
"no-proto": "error",
"no-return-assign": ["error", "always"],
"no-sequences": ["error", { "allowInParentheses": false }],
"no-shadow": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-useless-concat": "error",
"no-useless-rename": "error",
"no-void": "error",
"prefer-arrow-callback": "error",
"prefer-numeric-literals": "error",
"unicode-bom": "error",
// eval
"no-eval": "error",
"no-implied-eval": "error",
"no-new-func": "error",
"no-script-url": "error",
// complexity
"complexity": ["warn", 20],
"id-length": ["warn", { "min": 1, "max": 30 }],
"max-depth": ["warn", 4],
"max-lines-per-function": ["warn", {
"max": 60,
"skipBlankLines": true,
"skipComments": true,
}],
"max-nested-callbacks": ["warn", 4],
"max-params": ["warn", 4],
// stylistic
"@stylistic/quotes": ["error", "double", { "avoidEscape": true }],
"@stylistic/brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"@stylistic/no-multiple-empty-lines": ["error", { "max": 2 }],
"@stylistic/max-statements-per-line": ["error", { "max": 2 }],
"@stylistic/object-curly-spacing": ["error", "always", { "emptyObjects": "never" }],
},
},
{
files: ["sources/tests/*.js", "*.config.*js"],
languageOptions: {
globals: globals.node,
},
},
{
files: ["sources/**/*.json"],
plugins: { json },
language: "json/json",
extends: ["json/recommended"],
},
{
files: ["sources/**/*.css"],
plugins: { css },
language: "css/css",
extends: ["css/recommended"],
languageOptions: {
tolerant: true,
},
rules: {
/* allowUnknownVariables suppresses errors from variables defined in other files.
Stylelint does proper checking for this kind of error with its `referenceFiles` feature. */
"css/no-invalid-properties": ["error", { "allowUnknownVariables": true }],
"css/use-baseline": ["warn", {
"available": "widely",
"allowProperties": [
"backdrop-filter", // baseline 2024
],
"allowPropertyValues": {
"background-attachment": ["fixed"], // only unavailable in iOS
},
"allowAtRules": [
"starting-style", // baseline 2024
],
}],
"css/no-important": "warn",
},
},
]);
Loading