Skip to content

structure

Structure rules that no standard linter ships, at level all: lone files, shared name prefixes, file and folder clashes, long files, trivial functions, and environment reads outside the environment readers.

Check Stage Level What it does
structure/lone-files commit all Finds a folder that holds one code file and nothing else.
structure/shared-prefixes commit all Finds sibling files that share a name prefix, such as asset-card, asset-list, and asset-row.
structure/file-folder-clashes commit all Finds a file and a folder with one stem in the same place, such as turn.ts beside turn/.
structure/long-files commit all Checks the code line count of each file against the limit for its language.
structure/trivial-functions commit all Finds functions with too few statements and files that only forward to other code.
structure/environment-readers commit all Finds environment reads outside the files listed in structure.environment_readers.
Setting What it sets
limits.file_lines The most lines one file may have, not counting blank lines and comment-only lines.
limits.function_lines The most lines one function may have.
limits.function_parameters The most parameters one function may take.
limits.function_statements The most statements one function may have.
limits.block_nesting How deep blocks may nest inside one function.
limits.callback_nesting How deep callbacks may nest.
limits.cognitive_complexity The highest sonarjs cognitive score one function may have; the score grows as the function gets harder to follow.
limits.cyclomatic_complexity The most paths that may run through one function.
limits.function_branches The most branches one function may have.
limits.function_returns The most return statements one function may have.
limits.function_assignments The most variable assignments one shell function may make.
limits.closure_lines The most lines one Swift closure may have.
limits.type_lines The most lines one Swift type body may have.
limits.index_exports The most re-exports one index file may hold.
limits.trivial_function_statements Report functions with this many statements or fewer; any whole number from 1 up works, a higher number reports more functions, and limits.<language> sets it for one language.
limits.shared_prefix_files The number of siblings sharing a name prefix that makes a finding.
structure.reexports Where re-exports may go: none, or an index file that re-exports other files.
structure.environment_readers The files that may read environment variables; other files get the values passed in.
import_rule Code may import its own files and the files of every import rule listed above it, never below. can_also_import names import rules listed below it.

Always selected.