All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Improved detection of string-literals that definitely don't coerce to numbers. Limited to literals that can be detected in the current scope, but an improvement:
const foo = 'one'
const bar = 'two'
// Before v2.2.0:
foo + bar
// -> BigNumber.sum(foo, bar)
// After v2.2.0:
foo + bar
// -> foo + bar
- New configuration option:
unsafelyIgnoreSuggestionsForOperators
{
"plugins": ["big-number-rules"],
"settings": {
"big-number-rules": {
"unsafelyIgnoreSuggestionsForOperators": ["+", "+="]
}
}
}
BREAKING CHANGES:
-
Offer
String#concat()
andTemplate String
replacements for+
related rules, in addition to the default BigNumber suggestion. -
Offer
Object.is()
replacement for===
related rules, in addition to the default BigNumber suggestion.
Since these are now multiple suggestions instead of just one fix, these rules no longer auto-fix, hence the major version bump.
decimalPlaces
specifies a maximum number of DPs, not a fixed number, so is not a valid substitute fortoFixed
.- Update README to reflect this fix.
-
bitwise + comparison rules are now separate from arithmetic rules:
// .eslintrc { "plugins": ["big-number-rules"], "rules": { "big-number-rules/arithmetic": "warn", "big-number-rules/bitwise": "warn", "big-number-rules/comparison": "warn" } }
These rules are also part of
big-number-rules/recommended
:// .eslintrc { "plugins": ["big-number-rules"], "extends": ["plugin:big-number-rules/recommended"] }
- Updated match-iz, fix recusion
- Remove build process to permit better debugging opportunities.
- Target
imported
rather thanlocal
specifier
- Small refactor using
sift-r
-
New option for ESM files:
importSpecifier
. Works in conjunction withimportDeclaration
option to further guard against running rules unless the specified import is met.For example:
// .eslintrc { "settings": { "big-number-rules": { "importDeclaration": "my-lib.js", "importSpecifier": "NumberProcessor" } } }
With this config, rules will only be applied to files with the following import:
import NumberProcessor from 'my-lib.js' import { NumberProcessor } from 'my-lib.js' import { BigNumber as NumberProcessor } from 'my-lib.js'
The rules will not apply if
my-lib.js
is imported withoutNumberProcessor
.
- Dependencies
- Update deprecated match-iz pattern
- Update deps, rebuild
- Minor refactoring
- Refactor some rules to use pattern-matching
- Improve README floating-point explanation
isNaN
transformations were incorrect
- Update README with negation examples
- Support for transforming
!==
and!=
- Include
importDeclaration
at top of README to help the quick-starters
importDeclaration
rule was only applying to the first import
-
New option for ESM files:
importDeclaration
. Defaults to "IGNORE", but if specified the plugin will only apply its rules to files that include an import statement matching it.For example, if
importDeclaration
is"my-lib.js"
, the plugin will only apply rules to a file if it sees the following import:import whatever from 'my-lib.js'
- Correct date on 1.5.6 changelog entry
- Improve
isNaN
rule to only operate on global/Number namespace
- Avoid warnings on expressions that use
.length
-- very unlikely to be financial calculations
- Avoid warnings on stuff that's obviously string concatenation
- Update README with info on applying per-file rules
- Support bitwise double-not (
~~
) used for floor'ing
- Assignment replacements should include an assignment :P
- Rules for assignment-expressions (
+=
,-=
, etc.) (big-number-rules/assignment)
- Move comparison-operators into their own sub-config. No rule-changes
- README updates + corrections, dep-updates
- Bundle to target node>=10 instead of 14
- Missing README link to example .eslintrc for big.js
- Bitwise settings are now their own thing
- Added some example settings files for different libraries.
-
Optionally prefer
plus
for libraries that don't supportsum
withsupportsSum
setting. -
Can now offer replacements for
Math.round|ceil|floor
for libraries that support it. -
Refactored test-suite so it will test the example settings files.
- Settings overrides were referencing old namespace
- Update README config link
toExponential
,toPrecision
,toString
- Instead of a function, you can now use a JSON-friendly array to configure the more detailed overriding of binary-expressions in
.eslintrc
. See the<<
operator for reference.
- Recommended rules setting:
big-number-rules/recommended
- Post-publishing README tweaks
- eslint-plugin-big-number-rules :)