# Optional ESLint config Source: https://smartassertions.dev/eslint-config-rules/ Index of every page: https://smartassertions.dev/llms.txt The `@kensio/smartass` package also exports an optional ESLint flat config that discourages less specific assertion usage. For example: ```typescript assertIdentical(foo.length, 2); // suggested improvement: assertArrayLength(foo, 2); ``` You can use this in your ESLint config like this: ```typescript import { defineConfig } from "eslint/config"; import tseslint from "typescript-eslint"; import { smartassPreferSpecificAssertions } from "@kensio/smartass/eslint"; export default defineConfig( ...tseslint.configs.recommended, ...smartassPreferSpecificAssertions, ); ``` The same suggestions are available as an [Oxlint plugin](https://smartassertions.dev/oxlint-plugin-rules/). Both are generated from a single table of selectors, so the two linters report identically and you only need whichever one you already run. Some more examples of the replacements that the ESLint rules will suggest: - `assertIdentical(value, true)` → `assertTrue(value)` - `assertIdentical(value, false)` → `assertFalse(value)` - `assertIdentical(value, undefined)` → `assertUndefined(value)` - `assertTrue(value != null)` → `assertNonNullable(value)` - `assertIdentical(typeof value, "string")` → `assertTypeString(value)` - `assertIdentical(value instanceof MyClass, true)` → `assertInstanceOf(value, MyClass)` - `assertIdentical("key" in object, true)` → `assertObjectHasProperty(object, "key")` - `assertIdentical(value.length, expected)` → `assertArrayLength()` etc. - `assertIdentical(value.size, expected)` → `assertSetSize()` etc. - `assertTrue(array.length > 0)` → `assertArrayNotEmpty(array)` - `assertTrue(value.includes(expected))` → `assertStringIncludes()` etc. - `assertTrue(value.startsWith(prefix))` → `assertStringStartsWith(value, prefix)` - `assertTrue(value.endsWith(suffix))` → `assertStringEndsWith(value, suffix)` - `assertTrue(stats.isDirectory())` → `assertDirectoryExists()` etc.