src/content/docs/linter/rules/no-redundant-use-strict.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noRedundantUseStrict`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). ## How to configure ```json title="biome.json" { "linter": { "rules": { "suspicious": { "noRedundantUseStrict": "error" } } } }## Description
Prevents from having redundant `"use strict"`.
The directive `"use strict"` **isn't** needed in `.mjs` files, or in `.js` files inside projects where the `package.json` defines library as module:
```json
{
"type": "module"
}
Instead, .cjs files are considered "scripts" and the directive "use strict" is accepted and advised.
"use strict";
function foo() {
"use strict";
}
"use strict";
"use strict";
function foo() {
}
function foo() {
"use strict";
"use strict";
}
class C1 {
test() {
"use strict";
}
}
const C2 = class {
test() {
"use strict";
}
};
function foo() {
}
function foo() {
"use strict";
}
function bar() {
"use strict";
}