0
0
mirror of https://github.com/jellyfin/jellyfin.org.git synced 2025-05-10 03:15:27 +00:00
Files
jellyfin.org/docs/general/style-guides/javascript.md
2023-06-02 20:12:35 -07:00

1.2 KiB

uid, title
uid title
style-guides-javascript JavaScript

JavaScript

Filenames

Filenames must be camel case and may not include underscores (_) or dashes (-). The filename's extensions must be .js.

File Structure

All files must abide by the following general structure, with JSDoc comments being optional but preferred.

/**
 * This module documents the structure used by JavaScript code in Jellyfin.
 *
 * @module path/to/this/module
 */

import module from 'dependency';
import { myFunction, myClass } from 'dependency/submodule';
import 'otherDependency';

/**
 * Defines a non-exported function, accessible only from this module.
 *
 * @param {Object} argument - The argument to pass to the function.
 * @returns {Int|null} The resulting object from the function.
 */
function privateFunction (argument) {
    // Code omitted
}

export function publicFunction (argument) {
    // Code omitted
}

export default { publicFunction }

Miscellaneous

File Encoding

All files must be encoded in UTF-8 and use LF line endings when committed.

Non-ASCII Characters

For printable characters, use the actual Unicode character directly in your code.

For non-printable characters, use the hexadecimal or Unicode escape.