eslint-plugin-unicorn

More than 100 powerful ESLint rules

MIT License

Downloads
11.8M
Stars
3.9K
Committers
152

Bot releases are hidden (Show)

eslint-plugin-unicorn -

Published by sindresorhus over 2 years ago

The project has passed 100 lint rules 🎉

Thanks to everyone that has contributed so far.

And special thanks to our team member @fisker for doing most of the work on this project. We could not have gotten this far without him.

New rules

Improvements

  • template-indent: Set the rule error instead of warn in recommended preset (#1781) 09923af
  • prefer-json-parse-buffer: Remove from recommended preset (#1750) 93f49f2
  • no-array-for-each: Add fixer for parenthesized call (#1784) 5f39c37
  • no-array-for-each: Handle optional chaining (#1753) 1d32db4
  • prefer-object-from-entries: Stop checking unknown cases (#1771) 309771d
  • prefer-string-trim-start-end: Check optional chaining (#1768) 1920597
  • no-useless-undefined: Ignore arguments in Function#bind() (#1762) c501243
  • prefer-ternary: Skip fix if there are comments (#1763) 3013565
  • text-encoding-identifier-case: Auto-fix encoding in fs.{readFile,readFileSync}() (#1755) 5e1c932
  • Add dist and dst abbreviations (#1756) dffcea8

Fixes

  • no-array-for-each: Handle ChainExpression correctly (#1772) e615a37

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v41.0.1...v42.0.0

eslint-plugin-unicorn -

Published by sindresorhus over 2 years ago

eslint-plugin-unicorn -

Published by sindresorhus over 2 years ago

New rules

Breaking

  • Require ESLint 8 (#1724) 608a90c

Fixes

  • prefer-export-from: Fix TypeScript compatibility (#1728) f14aa95
  • prefer-at: Remove auto-fix for arguments (#1705) bba518e

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v40.1.0...v41.0.0

eslint-plugin-unicorn -

Published by sindresorhus almost 3 years ago

  • expiring-todo-comments: Add date option (#1683) 16bc33a
  • consistent-function-scoping: Allow React.useHook (#1691) e910633
  • no-useless-undefined: Allow React.createContext(undefined) (#1688) 40bc603

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v40.0.0...v40.1.0

eslint-plugin-unicorn -

Published by sindresorhus almost 3 years ago

New rules

Improvements

  • prefer-object-has-own: Deprecate in favor of the built-in prefer-object-has-own rule (#1646) e59a856
  • filename-case: Ignore $ in filenames (#1628) a43a174
  • no-useless-promise-resolve-reject: Detect unnecessary Promise.resolve/reject in promise callback functions (#1666) f6215f3
  • prefer-export-from: Support import assertions (#1618) 1d7a6b6
  • prefer-top-level-await: Improve top-level expression detection (#1526) b054d65
  • prefer-dom-node-dataset: Check .hasAttribute() and .getAttribute() (#1673) 152f153
  • prefer-dom-node-dataset: Check .removeAttribute() (#1668) 22d8d03
  • prefer-string-slice: Improve fix (#1675) 267115a
  • prefer-math-trunc: Improve fix logic (#1670) 784c7a8
  • prefer-string-slice: Improve argument type detection (#1664) 03b0946
  • prefer-add-event-listener: Remove fix for onerror (#1650) 7bf63bb
  • no-array-push-push: Ignore process.{stdin,stdout,stderr} (#1654) 10ad699
  • no-new-array & no-new-buffer: Improve argument type detection (#1648) 9b04e43
  • no-array-for-each: Ignore pIteration.forEach (#1649) 2b92385
  • no-array-callback-reference: Ignore primitive wrappers in Array#map() (#1642) 0362c09
  • prefer-export-from: Support "string literal specifier" (#1636) 0866b41
  • template-indent: Check Jest inline snapshots by default (#1637) 64460e2

Fixes

  • prefer-dom-node-dataset: Fix name conversion (#1674) 7fb6f7b
  • prefer-export-from: Fix crash in TypeScript files (#1647) 1ff8e42

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v39.0.0...v40.0.0

eslint-plugin-unicorn -

Published by sindresorhus almost 3 years ago

New rules

Improvements

  • prefer-export-from: Add ignoreUsedVariables option (#1590) a8d52e4
  • prevent-abbreviations: Show file basename instead of full path (#1593) 7c2867d
  • Remove require-post-message-target-origin rule from recommended config (#1581) 014b4dc

Fixes

  • no-empty-file: Fix false positive with triple-slash directives (#1605) 6354bb8
  • require-number-to-fixed-digits-argument: Ignore .toFixed from new expression (#1601) 20d61e7
  • prefer-export-from: Fix bug on fixing export namespace as default (#1583) b564ff1
  • Add missing additionalProperties to schema (#1589) 579d05d

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v38.0.1...v39.0.0

eslint-plugin-unicorn -

Published by sindresorhus almost 3 years ago

  • prefer-export-from: Ignore variables with type (#1580) ea49b21

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v38.0.0...v38.0.1

eslint-plugin-unicorn -

Published by sindresorhus almost 3 years ago

New rules

Improvements

  • Ignore Ramda methods in rules (#1557) 5f3bad5
  • no-array-callback-reference: Only ignore Boolean in reasonable places (#1570) 46f8638
  • require-array-join-separator: Check optional member (#1569) 15f9028

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v37.0.1...v38.0.0

eslint-plugin-unicorn -

Published by sindresorhus about 3 years ago

eslint-plugin-unicorn -

Published by sindresorhus about 3 years ago

New rules

Improvements

  • Support ESLint 8 (#1488) e97ab7e
  • Use 'latest' as ecmaVersion (#1465) 9feb181

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v36.0.0...v37.0.0

eslint-plugin-unicorn -

Published by sindresorhus about 3 years ago

New rules

Improvements

  • Add all config (#1512) a512ad1
    • This config includes all the rules, except deprecated ones.
  • prefer-spread: Check String#split('') (#1489) d51a197
  • prefer-module: Use suggestions for 'use strict' directive (#1470) 57c7906
  • error-message: Handle shadowed Error constructor (#1496) fdadd88

Fixes

  • prefer-spread: Fix false negative on array constants (#1474) 4162145

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v35.0.0...v36.0.0

eslint-plugin-unicorn -

Published by sindresorhus about 3 years ago

New rules

Breaking

  • explicit-length-check: Remove greater-than-or-equal option (#1397) db1a2b5
    • It enabled a style that no one actually uses.

Improvements

  • no-array-reduce: Add allowSimpleOperations option (#1418) 153eb2c
  • no-array-callback-reference: Ignore jQuery methods (#1457) 7af9a6f
  • prevent-abbreviations: Ignore i18n and l10n (#1445) efdd90e
  • no-array-callback-reference: Ignore mobx-state-tree usage (#1455) 73c0dfd
  • new-for-builtins: Check WeakRef and FinalizationRegistry (#1450) fce9d1d
  • no-zero-fractions: Handle .0 correctly (#1444) fcca35d
  • new-for-builtins: Enforce new for SharedArrayBuffer and Proxy (#1438) 2ba83ad
  • no-null: Allow Object.create(null, …) (#1432) 768f301
  • number-literal-case: Support Vue SFC (#1434) ee9f609
  • no-object-as-default-parameter: Forbid destructuring (#1433) 3fcc4bb
  • prefer-spread: Better auto-fix (#1426) 7bdf0dd
  • prefer-array-some: Check cases comparing .find() with undefined (#1422) 3dc2f77
  • no-useless-spread: Check useless "iterable to array" (#1414) 61bc6a3
  • prefer-dom-node-text-content: Check destructuring, Use suggestion instead of auto-fix (#1417) c4bfc42
  • require-post-message-target-origin: Disable for TypeScript files (#1415) 741484a
  • prefer-add-event-listener: Update event types list (#1412) 7f88b2f
  • no-instanceof-array: Support Vue SFC (#1410) 3b22917
  • prevent-abbreviations: Add def (#1402) f783472
  • no-instanceof-array: Improve report location (#1389) 6512fbd
  • Use original quote when auto-fixing (#1411) bb81582

Fixes

  • throw-new-error: Fix an edge case (#1390) 806831b
  • Fix cases without space after keywords (#1436) 179b7df

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v34.0.1...v35.0.0

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

  • no-array-method-this-argument: Fix false positives (#1386) d364d67

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v34.0.0...v34.0.1

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

New rules

Improvements

  • prefer-module: Ignore .cjs files (#1355) ebdc3c2
  • error-message: Support AggregateError (#1351) e7b4300
  • filename-case: Enforce lowercased file extension (#1336) 119615b
  • expiring-todo-comments: More helpful error when no conditions (#1375) 914a996
  • prefer-array-some and prefer-regexp-test: Support Vue SFC (#1364) a46050e
  • explicit-length-check: Support v-show directive (#1363) f163c4a
  • explicit-length-check: Support Vue SFC files (#1360) 9199611
  • prefer-type-error: Improve report location (#1354) bc3d58b
  • no-useless-undefined: Ignore Set#add() Map#set() Array#{push,unshift}() (#1353) c6359c3
  • prefer-prototype-methods: Only check methods from [] and {} (#1347) 29a4e75
  • prefer-array-some: Report non-zero check on array.filter().length (#1337) f8aaac2
  • Use context.getPhysicalFilename() (#1344) e2540cb

Fixes

  • prefer-array-find and prefer-at: Fix crash on LHS zero index access (#1373) da1f6d8
  • prefer-prototype-methods: Fix a missing condition on object literal check (#1332) cec7f11

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v33.0.1...v34.0.0

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

  • prefer-prototype-methods: Ignore known object literal methods (#1330) 639e7af

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v33.0.0...v33.0.1

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

New rules

Improvements

  • no-array-for-each: Handle only return statement inside if or else (#1319) 298a104
  • new-for-builtins & no-new-buffer: Handle line breaks after new keyword (#1301) d37439f
  • prefer-array-flat-map: Remove check on [].concat(...array.map(…)) (#1299) 128b5aa
  • prefer-spread: Ignore {arrayBuffer,blob,buffer,file,this}.slice() (#1287) e18d5f2
  • prefer-string-starts-ends-with: Add suggestions for safely handling non-strings (#1277) f14a9d1
  • explicit-length-check: Ignore this.{size,length} (#1289) ed85d00
  • prefer-string-starts-ends-with-rule: Don't autofix known non-string values (#1281) a1c8984
  • explicit-length-check: Ignore known, non-number length properties (#1264) 42f6487
  • empty-brace-spaces: Support experimental syntax (#1276) fa68b6f
  • prefer-dom-node-remove: Improve parentheses handling (#1254) 74e4d39

Fixes

  • prefer-array-flat: Fix incorrect fix, check Array.prototype.concat.call (#1317) f6a939c

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v32.0.1...v33.0.0

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

  • prevent-abbreviations: Fix shorthand import/export detection (#1252) 4367479

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v32.0.0...v32.0.1

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

Breaking

New rules

Improvements

  • no-for-loop: Ignore known non-array loop variables (#1242) 29f6b45
  • prefer-array-find: Singularize variable name in autofix (#1243) 6b340a3
  • prefer-switch: Do not add braces to the default case (#1235) c241782
  • no-zero-fractions: Handle numeric separators, fix missing parentheses, improve report location (#1238) 2724afa
  • no-array-for-each: Better error message (#1239) 2e82dc8
  • prefer-switch: Avoid conflict with no-unreachable rule (#1234) 1c78d0c
  • prefer-optional-catch-binding: Support checking destructured errors (#1229) a0b2f4f
  • no-array-for-each: Support autofixing complicated parameters (#1228) d84143f
  • prefer-negative-index: Support Array#at() (#1217) 6443ee3
  • explicit-length-check: Check Set#size (#1226) 6a745a0
  • filename-case: Improve report position (#1227) 3d4ac1b

Fixes

  • prevent-abbreviations: Fix shorthand import/export detection (#1215) a669e31

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v31.0.0...v32.0.0

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

eslint-plugin-unicorn -

Published by sindresorhus over 3 years ago

New rules

Breaking

  • prevent-abbreviations: Rename options (#1164) cf42cc5
  • no-keyword-prefix: Rename blacklist option to disallowedPrefixes (#1180) 91e60d0

Improvements

  • no-array-push-push: Add ignore option (#1168) f9262d9
  • prefer-spread: Report array.slice(0) (#1182) 92bebe1
  • no-useless-undefined: Handle parenthesized undefined (#1178) c88882e
  • no-array-for-each: Improve fixable parameter detection (#1177) 18d1ac2
  • prefer-array-flat-map: Exclude React.Children.map().flat() (#1159) 3e6b6fb
  • better-regex: Report parsing errors (#1133) 51ee030
  • filename-case: Uniquify suggestion filenames (#1160) a87238f
  • Support PropertyDefinition (#1127) 75c4d78

Fixes

  • prefer-number-properties: Fix some edge cases (#1170) e7e25b8
  • prefer-number-properties: Fix some edge cases (part 2) (#1176) 3a58802
  • prefer-regexp-test: Do not fix if regexp has g flag (#1173) 8d97beb
  • no-array-for-each: Do not fix if callback parameter has type annotation (#1167) 0d4fc8b
  • no-useless-undefined: Do not report return undefined if function has returnType (#1165) 4ff39e0
  • prefer-set-has: Use suggestions if node has type annotation (#1158) 1221185
  • no-null: Exclude second argument of Node.insertBefore() (#1157) b16c316
  • prefer-add-event-listener: Fix crash on parenthesized cases (#1153) c95e854
  • Fix optional MemberExpression check when using ecmaVersion: 2019 (#1151) 56d5d9a
  • prefer-regexp-test: Do not fix if argument of String#match() is known not RegExp (#1152) 0abc394

https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v29.0.0...v30.0.0

Package Rankings
Top 0.62% on Npmjs.org
Top 9.55% on Proxy.golang.org
Top 19.29% on Repo1.maven.org
Badges
Extracted from project README
Coverage Status npm version