5etools Documentation
repository·main·Indexed 19 days ago
https://github.com/5etools-mirror-3/5etools-srcA comprehensive digital toolkit for Dungeons & Dragons 5th Edition providing rules, data, and character management tools. This repository contains the source code for version 2.33.3, including ESLint configurations for code quality, implementation details for web app metadata and favicons, and developer guidance on the toolsLoaded event.
What's inside 5etools
Get help and support for 5e.tools
mainFor FAQs, installation guides, supported integrations, and other support resources, refer to the official 5e.tools wiki.Implement the updated favicon and web app metadata
mainTo support the updated favicon set, Chrome Web App icons, Windows Start Menu tiles, and Apple Touch icons, include the following HTML snippet within the
<head>section of every page. This ensures consistent branding across different platforms, including Android splash screens, Safari pinned tabs, and standalone app mode.<!-- Favicons --> <link rel="icon" type="image/svg+xml" href="favicon.svg"> <link rel="icon" type="image/png" sizes="256x256" href="favicon-256x256.png"> <link rel="icon" type="image/png" sizes="144x144" href="favicon-144x144.png"> <link rel="icon" type="image/png" sizes="128x128" href="favicon-128x128.png"> <link rel="icon" type="image/png" sizes="64x64" href="favicon-64x64.png"> <link rel="icon" type="image/png" sizes="48x48" href="favicon-48x48.png"> <link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png"> <!-- Chrome Web App Icons --> <link rel="manifest" href="manifest.webmanifest"> <meta name="application-name" content="5etools"> <meta name="theme-color" content="#006bc4"> <!-- Windows Start Menu tiles --> <meta name="msapplication-config" content="browserconfig.xml"/> <meta name="msapplication-TileColor" content="#006bc4"> <!-- Apple Touch Icons --> <link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon-180x180.png"> <link rel="apple-touch-icon" sizes="360x360" href="apple-touch-icon-360x360.png"> <link rel="apple-touch-icon" sizes="167x167" href="apple-touch-icon-167x167.png"> <link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-152x152.png"> <link rel="apple-touch-icon" sizes="120x120" href="apple-touch-icon-120x120.png"> <meta name="apple-mobile-web-app-title" content="5etools"> <!-- macOS Safari Pinned Tab and Touch Bar --> <link rel="mask-icon" href="safari-pinned-tab.svg" color="#006bc4">ESLint configuration for JavaScript files
mainThe project uses a flat configuration file (
eslint.config.mjs) to enforce coding standards across.js,.cjs, and.mjsfiles. The configuration extends@eslint/jsrecommended settings and applies specific rules for indentation, spacing, and syntax safety.Key Language Options
- ECMAScript Version:
latest - Source Type:
module - Globals: Includes both
browserandnodeenvironments.
Core Coding Standards
- Indentation: Uses
tabindentation with a1space indent forSwitchCase. - Quotes: Enforces
doublequotes, while allowing template literals. - Semicolons: Set to
warnand must always be present. - Spacing: Strict rules for
arrow-spacing,block-spacing,comma-spacing,keyword-spacing, andspace-before-function-paren(always). - Variables: Enforces
no-var(useletorconst) andone-var(initialized variables should not be grouped). - Equality: Enforces
eqeqeq(strict equality), ignoringnullchecks.
Ignored Files
Files and directories specified in the
CONFIG_IGNORESconstant (imported from../test/eslint/eslint-config.js) are excluded from linting.// Example of the configuration structure applied to JS files { files: ["**/*.js", "**/*.cjs", "**/*.mjs"], languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: { ...globals.browser, ...globals.node } }, rules: { "indent": ["error", "tab", { "SwitchCase": 1 }], "quotes": ["error", "double", { "allowTemplateLiterals": true }], "no-var": "error" } }- ECMAScript Version:
ESLint configuration for 5etools
mainThe project uses ESLint for code quality and style enforcement. The configuration is defined in
eslint.config.mjsusing the Flat Config format. It targets.js,.cjs, and.mjsfiles and includes the following key settings:- Language Options: Uses
ecmaVersion: "latest",sourceType: "module", and includesglobals.browserto support browser-based environments. - Plugins: Includes
vet-jquery(from5etools-utils/eslint) to validate jQuery usage. - Formatting: Enforces strict formatting rules such as
tabindentation,1tbsbrace style, and mandatory semicolons. - Exclusions: Uses
CONFIG_IGNORES(imported from./test/eslint/eslint-config.js) to define ignored files.
- Language Options: Uses
Listen for the toolsLoaded event
mainThe application dispatches a global
toolsLoadedevent on thewindowobject once the initial loading sequence is complete. This sequence includes initializing core utilities (PrereleaseUtil,BrewUtil2,ExcludeUtil), setting up DOM elements, and attaching hash change listeners. Developers should listen for this event to ensure the application state is ready for interaction.window.addEventListener('toolsLoaded', () => { // Application is ready });Reference: ESLint rules and settings
mainThe following rules and configurations are applied to JavaScript files in the repository. This list is used to maintain code consistency and catch potential errors.
// Core Configuration languageOptions: { ecmaVersion: "latest", sourceType: "module", globals: { ...globals.browser } }, // Key Rules "vet-jquery/jquery": "warn", "indent": ["error", "tab", { "SwitchCase": 1 }], "quotes": ["error", "double", { "allowTemplateLiterals": true }], "semi": ["error", "always"], "no-var": "error", "no-console": "error", "prefer-template": "error", "eqeqeq": ["error", "always", { "null": "ignore" }], "no-unused-vars": "off", "no-undef": "off"