src/content/docs/linter/rules/use-shorthand-assign.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.3.0` - Diagnostic Category: [`lint/style/useShorthandAssign`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule has an [**unsafe**](/linter/#unsafe-fixes) fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`operator-assignment`](https://eslint.org/docs/latest/rules/operator-assignment){
"linter": {
"rules": {
"style": {
"useShorthandAssign": "error"
}
}
}
}
Require assignment operator shorthand where possible.
JavaScript provides shorthand operators combining a variable assignment and simple mathematical operation.
a = a + 1;
a = a - 1;
a = a * 1;
a += 1;
a -= 1;
a *= 1;