Rome is a toolchain for the web: formatter, linter and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS
—
Rome's linter provides static analysis and code quality checks that replace ESLint, with extensive rules for correctness, performance, accessibility, security, and style. It includes automatic fixing capabilities for many issues.
The primary linting command that analyzes files for issues and optionally applies fixes.
/**
* Run the linter on a set of files
*
* Usage: rome check [OPTIONS] <INPUTS...>
*
* INPUTS can be one or more filesystem paths, each pointing to a single file
* or an entire directory to be searched recursively for supported files
*/
rome check <INPUTS...>Core Options:
--apply # Apply safe fixes automatically
--apply-suggested # Apply safe and suggested fixes automatically
--max-diagnostics <number> # Cap the amount of diagnostics displayed (default: 20)
--verbose # Print additional verbose advice on diagnosticsUsage Examples:
# Check files without fixing
rome check src/
# Apply safe fixes only
rome check src/ --apply
# Apply both safe and suggested fixes
rome check src/ --apply-suggested
# Limit diagnostic output
rome check src/ --max-diagnostics=10
# Verbose diagnostic information
rome check src/ --verboseRome categorizes fixes into different safety levels:
# Safe fixes: Low-risk changes that preserve code behavior
--apply
# Suggested fixes: Higher-risk changes that may alter behavior
--apply-suggestedRules that enforce web accessibility best practices.
{
"linter": {
"rules": {
"a11y": {
"recommended": true,
"noAutofocus": "error", // Avoid autoFocus attribute
"noBlankTarget": "error", // Disallow target="_blank" without rel="noreferrer"
"noPositiveTabindex": "error", // Prevent positive tabIndex values
"useAltText": "error", // Require alt text for images
"useAnchorContent": "error", // Enforce anchor element content
"useButtonType": "error", // Enforce button type attribute
"useKeyWithClickEvents": "error", // Require keyboard events with click events
"useKeyWithMouseEvents": "error" // Require keyboard events with mouse events
}
}
}
}Rules that enforce code complexity limits and maintainability.
{
"linter": {
"rules": {
"complexity": {
"recommended": true,
"noBannedTypes": "error", // Disallow certain built-in types
"noExtraBooleanCast": "error", // Avoid unnecessary boolean casts
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noStaticOnlyClass": "error", // Disallow classes with only static members
"noUselessCatch": "error", // Disallow unnecessary catch clauses
"noUselessConstructor": "error", // Disallow unnecessary constructors
"noUselessEmptyExport": "error", // Disallow empty export statements
"noUselessFragments": "error", // Disallow unnecessary React fragments
"noUselessLabel": "error", // Disallow unused labels
"noUselessRename": "error", // Disallow renaming import/export to same name
"noUselessSwitchCase": "error", // Disallow useless switch cases
"noWith": "error", // Disallow with statements
"useLiteralKeys": "error", // Enforce literal keys in objects
"useSimplifiedLogicExpression": "error" // Simplify boolean expressions
}
}
}
}Rules that catch potential bugs and logical errors.
{
"linter": {
"rules": {
"correctness": {
"recommended": true,
"noChildrenProp": "error", // Disallow children prop in React
"noConstAssign": "error", // Disallow reassigning const variables
"noConstantCondition": "error", // Disallow constant conditions
"noEmptyCharacterClassInRegex": "error", // Disallow empty character classes
"noEmptyPattern": "error", // Disallow empty destructuring patterns
"noGlobalObjectCalls": "error", // Disallow calling global objects as functions
"noInnerDeclarations": "error", // Disallow variable/function declarations in nested blocks
"noInvalidConstructorSuper": "error", // Disallow invalid super() calls
"noNewSymbol": "error", // Disallow new Symbol()
"noPrecisionLoss": "error", // Disallow numeric literals that lose precision
"noSelfAssign": "error", // Disallow self assignment
"noSetterReturn": "error", // Disallow return in setter
"noSwitchDeclarations": "error", // Disallow lexical declarations in switch clauses
"noUndeclaredVariables": "error", // Disallow undeclared variables
"noUnreachable": "error", // Disallow unreachable code
"noUnreachableSuper": "error", // Disallow unreachable super() calls
"noUnsafeFinally": "error", // Disallow unsafe control flow in finally blocks
"noUnusedLabels": "error", // Disallow unused labels
"noUnusedVariables": "error", // Disallow unused variables
"useIsNan": "error", // Require isNaN() when checking for NaN
"useValidForDirection": "error", // Enforce correct for loop directions
"useYield": "error" // Require yield in generator functions
}
}
}
}Rules that identify potential performance issues.
{
"linter": {
"rules": {
"performance": {
"recommended": true,
"noDelete": "error" // Disallow delete operator
}
}
}
}Rules that help prevent security vulnerabilities.
{
"linter": {
"rules": {
"security": {
"recommended": true,
"noDangerouslySetInnerHtml": "error", // Disallow dangerouslySetInnerHTML
"noGlobalEval": "error" // Disallow eval() in global scope
}
}
}
}Rules that enforce consistent code style.
{
"linter": {
"rules": {
"style": {
"recommended": true,
"noArguments": "error", // Disallow arguments object
"noCommaOperator": "error", // Disallow comma operator
"noImplicitBoolean": "error", // Disallow implicit boolean conversion
"noInferrableTypes": "error", // Disallow obvious type annotations
"noNamespace": "error", // Disallow TypeScript namespaces
"noNonNullAssertion": "error", // Disallow non-null assertions
"noParameterAssign": "error", // Disallow reassigning function parameters
"noParameterProperties": "error", // Disallow parameter properties
"noRestrictedGlobals": "error", // Disallow specific global variables
"noShoutyConstants": "error", // Disallow SHOUTY_CASE constants
"noUnusedTemplateLiteral": "error", // Disallow unused template literals
"noVar": "error", // Disallow var declarations
"useBlockStatements": "error", // Enforce block statements
"useCollapsedElseIf": "error", // Enforce collapsed else-if
"useConst": "error", // Enforce const for never-modified variables
"useDefaultParameterLast": "error", // Enforce default parameters last
"useEnumInitializers": "error", // Enforce enum initializers
"useExponentiationOperator": "error", // Enforce ** over Math.pow()
"useFragmentSyntax": "error", // Enforce React fragment syntax
"useNumericLiterals": "error", // Enforce numeric literals
"useSelfClosingElements": "error", // Enforce self-closing elements
"useShorthandArrayType": "error", // Enforce T[] over Array<T>
"useSingleCaseStatement": "error", // Enforce single case per switch statement
"useSingleVarDeclarator": "error", // Enforce single variable declarator
"useTemplate": "error", // Enforce template literals
"useWhile": "error" // Enforce while over for loops where appropriate
}
}
}
}Rules that flag potentially problematic code patterns.
{
"linter": {
"rules": {
"suspicious": {
"recommended": true,
"noArrayIndexKey": "error", // Disallow array index as key
"noAssignInExpressions": "error", // Disallow assignment in expressions
"noAsyncPromiseExecutor": "error", // Disallow async Promise executor
"noCatchAssign": "error", // Disallow reassigning catch clause parameter
"noClassAssign": "error", // Disallow reassigning class declarations
"noCommentText": "error", // Disallow comments in JSX text
"noCompareNegZero": "error", // Disallow comparing against -0
"noControlCharactersInRegex": "error", // Disallow control characters in regex
"noDebugger": "error", // Disallow debugger statements
"noDoubleEquals": "error", // Disallow == and !=
"noDuplicateCase": "error", // Disallow duplicate case labels
"noDuplicateClassMembers": "error", // Disallow duplicate class members
"noDuplicateJsxProps": "error", // Disallow duplicate JSX props
"noDuplicateObjectKeys": "error", // Disallow duplicate object keys
"noDuplicateParameters": "error", // Disallow duplicate parameters
"noEmptyBlockStatements": "error", // Disallow empty block statements
"noExplicitAny": "error", // Disallow explicit any type
"noExtraNonNullAssertion": "error", // Disallow extra non-null assertions
"noFallthroughSwitchClause": "error", // Disallow fallthrough switch cases
"noFunctionAssign": "error", // Disallow reassigning function declarations
"noGlobalAssign": "error", // Disallow assignments to native objects
"noImportAssign": "error", // Disallow assigning to imports
"noLabelVar": "error", // Disallow labels with variable names
"noMisleadingCharacterClass": "error", // Disallow misleading character class
"noPrototypeBuiltins": "error", // Disallow prototype builtins
"noRedeclare": "error", // Disallow variable redeclaration
"noRedundantUseStrict": "error", // Disallow redundant 'use strict'
"noSelfCompare": "error", // Disallow self comparison
"noShadowRestrictedNames": "error", // Disallow shadowing restricted names
"noSparseArray": "error", // Disallow sparse arrays
"noUnsafeNegation": "error", // Disallow unsafe negation
"useDefaultSwitchClauseLast": "error", // Enforce default clause last
"useGetterReturn": "error" // Enforce return in getters
}
}
}
}Each rule can be configured with different severity levels:
{
"linter": {
"rules": {
"correctness": {
"noUnusedVariables": "error", // Error level (breaks build)
"noConstAssign": "warn", // Warning level (reports but continues)
"noEmptyPattern": "off" // Disabled
}
}
}
}Enable or disable entire rule groups:
{
"linter": {
"enabled": true,
"rules": {
"recommended": true, // Enable all recommended rules
"a11y": {
"recommended": true // Enable recommended accessibility rules
},
"performance": {
"recommended": false, // Disable performance rules
"noDelete": "error" // But enable specific rule
}
}
}
}Configure files and patterns to ignore:
{
"linter": {
"ignore": [
"dist/**",
"node_modules/**",
"*.min.js",
"build/**/*.js"
]
}
}# Check all files in src directory
rome check src/
# Check specific files
rome check src/index.js src/utils.ts
# Check with custom file size limit
rome check src/ --files-max-size=2097152# Apply only safe fixes
rome check src/ --apply
# Apply all available fixes
rome check src/ --apply-suggested
# Check what would be fixed without applying
rome check src/ --verbose# Exit with error code if issues found
rome check src/
# Limit output for CI logs
rome check src/ --max-diagnostics=50
# JSON output for tooling integration
rome check src/ --jsonRome provides detailed diagnostic information:
0: No issues found1: Issues found (errors or warnings based on configuration)2: Configuration or runtime errorInstall with Tessl CLI
npx tessl i tessl/npm-rome