Skip to content

Commit

Permalink
chore(release): 127.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Aug 22, 2020
1 parent 4c61f16 commit 847fd6c
Show file tree
Hide file tree
Showing 16 changed files with 8,592 additions and 4,581 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ module.exports = {
"./lib/config/node.js",
],
overrides: [
// Source
{
extends: ["./lib/config/dirty.js"],
// Exclude nested tests
excludedFiles: ["**/__tests__/**/*", "**/__mocks__/**/*", "**/*.md"],
files: ["src/**/*"],
rules: {
// Allow to use ES module syntax
// You should use babel if your node version is not supported ES syntax module, dynamic loading ES modules or other features
"node/no-unsupported-features/es-syntax": [
"error",
{ ignores: ["modules", "dynamicImport"] },
],
},
},

// Tests
{
extends: ["./lib/config/dirty.js", "./lib/config/ava.js"],
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org). Except add new
rule (it is breaking changed by default).

## 127.0.0 - 2020-08-19

- Added: `no-loss-of-precision` rule.
- Added: `default-case-last` rule.
- Added: `no-promise-executor-return` rule.
- Added: `no-unreachable-loop` rule.
- Added: `use-t-throws-async-well` rule.
- Added: `no-useless-backreference` rule.
- Added: `unicorn/prefer-array-find` rule.
- Added: `unicorn/prefer-optional-catch-binding` rule.
- Added: `jest/no-interpolation-in-snapshots` rule.
- Added: `jest/no-deprecated-functions` rule.
- Added: `jest/no-conditional-expect` rule.
- Added: `jsx-a11y/autocomplete-valid` rule.
- Changed: `prefer-promise-reject-errors` rule allow empty `Promise.reject()`;
- Changed: `id-length` rule allow to use `a` and `b` identifiers (useful for comparison).
- Changed: `no-labels` allows to use `labels` in loops.
- Changed: minimum required `eslint` version is now `7.7.0`.
- Changed: minimum required `eslint-plugin-ava` version is now `11.0.0`.
- Changed: minimum required `eslint-plugin-html` version is now `6.0.3`.
- Changed: minimum required `eslint-plugin-import` version is now `2.22.3`.
- Changed: minimum required `eslint-plugin-jest` version is now `23.20.0`.
- Changed: minimum required `eslint-plugin-jsx-a11y` version is now `6.1.3`.
- Changed: minimum required `eslint-plugin-react` version is now `7.20.6`.
- Changed: minimum required `eslint-plugin-unicorn` version is now `21.0.0`.

## 126.0.0 - 2020-04-25

- Changed: minimum required `eslint-plugin-html` version is now `6.0.2`.
Expand Down
1 change: 1 addition & 0 deletions __tests__/all-rules/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-nodejs-modules
const path = require("path");

module.exports = {
Expand Down
31 changes: 25 additions & 6 deletions __tests__/fixtures/good.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ const numbers = [0, 1, 2];
multiply(1, ...numbers);

function fetch() {
return new Promise((resolve) => resolve("Some value"));
return new Promise((resolve) => {
resolve("Some value");
});
}

async function fetchJson(url) {
Expand Down Expand Up @@ -460,7 +462,7 @@ function doSomething() {

result = result * 2 + 10;

return resolve(result);
resolve(result);
});
}

Expand Down Expand Up @@ -572,10 +574,10 @@ handleHands(xBar, fooA, fooB, fooC, fooD);

try {
test = foo();
} catch (ignoreError) {
} catch {
try {
test = foo(1);
} catch (ignoreOtherError) {
} catch {
throw new Error("test");
}
}
Expand Down Expand Up @@ -681,10 +683,12 @@ console.log(new Bar().name());
function callbackInPromise(arg, callback) {
return new Promise((resolve, reject) => {
if (arg === 1) {
return reject(new Error("invalid"));
reject(new Error("invalid"));

return;
}

return resolve(arg);
resolve(arg);
}).then(() => callback());
}

Expand All @@ -696,6 +700,21 @@ function promiseInCallback(error, data) {
return Promise.resolve(data).then(() => `${data}string`);
}

let myLet = 10;
const myConst = 12;

myLet += 2;

console.log(myLet, myConst);

let myLet1 = 10;

const myConst1 = 12;

myLet1 += 2;

console.log(myLet1, myConst1);

export { foo, handler };
export {
age as ageExport,
Expand Down
2 changes: 2 additions & 0 deletions lib/config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = {
rules: {
"quote-props": 0,
Expand Down
6 changes: 4 additions & 2 deletions lib/config/rules/ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ module.exports = {
"ava/test-title": "error",
// Ensure test titles have a certain format
"ava/test-title-format": "off",
// Prevent the incorrect use of t.
"ava/use-t-well": "error",
// Ensure test functions use t as their parameter.
"ava/use-t": "error",
// Ensure that `t.throwsAsync()` and `t.notThrowsAsync()` are awaited.
"ava/use-t-throws-async-well": "error",
// Prevent the incorrect use of t.
"ava/use-t-well": "error",
// Ensure that AVA is imported with test as the variable name.
"ava/use-test": "error",
// Ensure that t.true()/t.false() are used instead of t.truthy()/t.falsy().
Expand Down
4 changes: 3 additions & 1 deletion lib/config/rules/best-practices.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module.exports = {
commentPattern: "^no default$",
},
],
// Enforce default clauses in switch statements to be last
"default-case-last": "error",
// Enforce default parameters to be last
"default-param-last": "error",
// Enforces consistent newlines before or after dots
Expand Down Expand Up @@ -192,7 +194,7 @@ module.exports = {
// Enforce using named capture group in regular expression
"prefer-named-capture-group": "off",
// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": ["error", { allowEmptyReject: false }],
"prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
// Disallow use of the RegExp constructor in favor of regular expression literals
"prefer-regex-literals": "error",
// Require use of the second argument for parseInt()
Expand Down
2 changes: 2 additions & 0 deletions lib/config/rules/ecmascript-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module.exports = {
"no-duplicate-imports": "off",
// Disallow use of the new operator with the Symbol object
"no-new-symbol": "error",
// Disallow specified names in exports
"no-restricted-exports": "off",
// Restrict usage of specified node imports
"no-restricted-imports": "off",
// Disallow to use this/super before super() calling in constructors.
Expand Down
8 changes: 8 additions & 0 deletions lib/config/rules/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
"jest/no-alias-methods": "error",
// Disallow commented out tests
"jest/no-commented-out-tests": "error",
// Disallow commented out tests
"jest/no-conditional-expect": "error",
// Disallow use of deprecated functions
"jest/no-deprecated-functions": "error",
// Disallow disabled tests
"jest/no-disabled-tests": "error",
// Disallow duplicate hooks within a describe block
Expand All @@ -29,6 +33,8 @@ module.exports = {
"jest/no-identical-title": "error",
// Disallow conditional logic
"jest/no-if": "off",
// Disallow string interpolation inside snapshots
"jest/no-interpolation-in-snapshots": "error",
// Disallow Jasmine globals
"jest/no-jasmine-globals": "error",
// Disallow importing `jest`
Expand All @@ -37,6 +43,8 @@ module.exports = {
"jest/no-large-snapshots": "off",
// Disallow manually importing from __mocks__
"jest/no-mocks-import": "error",
// Disallow specific matchers & modifiers
"jest/no-restricted-matchers": "off",
// Prevents `expect` statements outside of a `test` or `it` block
"jest/no-standalone-expect": "error",
// Using a callback in asynchronous tests
Expand Down
7 changes: 7 additions & 0 deletions lib/config/rules/jsx-a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ module.exports = {
"jsx-a11y/aria-role": ["error", { ignoreNonDom: false }],
// Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
"jsx-a11y/aria-unsupported-elements": "error",
// Enforce that autocomplete attributes are used correctly
"jsx-a11y/autocomplete-valid": [
"error",
{
inputComponents: ["Input", "FormField"],
},
],
// Enforce a clickable non-interactive element has at least one keyboard event listener.
"jsx-a11y/click-events-have-key-events": "error",
// Enforce heading (h1, h2, etc) elements contain accessible content.
Expand Down
8 changes: 8 additions & 0 deletions lib/config/rules/possible-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ module.exports = {
"no-invalid-regexp": "error",
// Disallow irregular whitespace outside of strings and comments
"no-irregular-whitespace": "error",
// Disallow literal numbers that lose precision
"no-loss-of-precision": "error",
// Disallow characters which are made with multiple code points in character class syntax
"no-misleading-character-class": "error",
// Disallow the use of object properties of the global object (Math and JSON) as functions
"no-obj-calls": "error",
// Disallow returning values from Promise executor functions
"no-promise-executor-return": "error",
// Disallow calling some Object.prototype methods directly on objects
"no-prototype-builtins": "error",
// Disallow multiple spaces in a regular expression literal
Expand All @@ -74,10 +78,14 @@ module.exports = {
"no-unexpected-multiline": "off",
// Disallow unreachable statements after a return, throw, continue, or break statement
"no-unreachable": "error",
// Disallow loops with a body that allows only one iteration
"no-unreachable-loop": "error",
// Disallow control flow statements in finally blocks
"no-unsafe-finally": "error",
// Disallow negating the left operand of relational operators
"no-unsafe-negation": "error",
// Disallow useless backreferences in regular expressions
"no-useless-backreference": "error",
// Disallow assignments that can lead to race conditions due to usage of `await` or `yield`
"require-atomic-updates": "error",
// Disallow comparisons with the value NaN
Expand Down
20 changes: 18 additions & 2 deletions lib/config/rules/stylistic-issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,31 @@ module.exports = {
// Enforce consistent line breaks inside function parentheses
"function-paren-newline": "off",
// Blacklist certain identifiers to prevent them being used
"id-blacklist": "off",
"id-denylist": "off",
// This option enforces minimum and maximum identifier lengths (variable names, property names etc.)
"id-length": [
"error",
{
min: 2,
max: Infinity,
properties: "always",
exceptions: ["$", "i", "j", "k", "v", "m", "n", "t", "_"],
exceptions: [
// jQuery
"$",
// Loops
"i",
"j",
"k",
"v",
"m",
"n",
"t",
// Lodash
"_",
// Comparison
"a",
"b",
],
},
],
// Require identifiers to match the provided regular expression
Expand Down
16 changes: 13 additions & 3 deletions lib/config/rules/unicorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,35 @@ module.exports = {
// Disallow nested ternary expressions. (partly fixable)
"unicorn/no-nested-ternary": "off",
// Disallow the use of the `null` literal.
// Maybe enable in future
"unicorn/no-null": "off",
// Disallow the use of objects as default parameters
"unicorn/no-object-as-default-parameter": "off",
// Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`
// Use `node/no-deprecated-api` rule.
"unicorn/no-new-buffer": "off",
// Disallow `process.exit()`
// Use `no-process-exit` `eslint` rule
"unicorn/no-process-exit": "off",
// Disallow `Array#reduce()` and `Array#reduceRight()`
"unicorn/no-reduce": "off",
// Disallow unreadable array destructuring.
"unicorn/no-unreadable-array-destructuring": "off",
// Disallow unsafe regular expressions.
"unicorn/no-unsafe-regex": "off",
// Disallow unused object properties.
"unicorn/no-unused-properties": "off",
// Disallow useless `undefined`
// No need, we use the `no-undefined` rule
"unicorn/no-useless-undefined": "off",
// Disallow number literals with zero fractions or dangling dots
"unicorn/no-zero-fractions": "error",
// Enforce lowercase identifier and uppercase value for number literals
// Use `prettier`
"unicorn/number-literal-case": "off",
// Prefer `addEventListener` over `on`-functions.
// "unicorn/prefer-add-event-listener": "off",
// Prefer `.find(…)` over the first element from `.filter(…)`
"unicorn/prefer-array-find": "error",
// Prefer using `.dataset` on DOM elements over `.setAttribute(…)`
// "unicorn/prefer-dataset": "off",
// Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`
Expand All @@ -105,6 +113,10 @@ module.exports = {
// "unicorn/prefer-node-append": "off",
// Prefer `remove` over `parentNode.removeChild` and `parentElement.removeChild`.
// "unicorn/prefer-node-remove": "off",
// Prefer Number static properties over global ones
"unicorn/prefer-number-properties": "error",
// Prefer omitting the `catch` binding parameter.
"unicorn/prefer-optional-catch-binding": "error",
// Prefer `querySelector` over `getElementById`, `querySelectorAll` over `getElementsByClassName` and `getElementsByTagName`
// "unicorn/prefer-query-selector": "off",
// Prefer `Reflect.apply()` over `Function#apply()`
Expand Down Expand Up @@ -133,8 +145,6 @@ module.exports = {
"unicorn/throw-new-error": "error",
// Prefer Set#has() over Array#includes() when checking for existence or non-existence
"unicorn/prefer-set-has": "off",
// Prefer Number static properties over global ones
"unicorn/prefer-number-properties": "error",

// Deprecated
"unicorn/regex-shorthand": "off",
Expand Down
4 changes: 1 addition & 3 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ module.exports = {
"*.{js,cjs,mjs,jsx,ts,tsx}": [
"prettier --list-different",
"eslint --report-unused-disable-directives",
"git add",
],
"*.{md,markdown,mdown,mkdn,mkd,mdwn,mkdown,ron}": [
"prettier --list-different",
"remark -f -q",
"git add",
],
"*.{yml,yaml}": ["prettier --list-different", "git add"],
"*.{yml,yaml}": ["prettier --list-different"],
};
Loading

0 comments on commit 847fd6c

Please sign in to comment.