Skip to content

Commit

Permalink
feat(unicorn): update and seperate rules (#43)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: major update to unicorn
  • Loading branch information
JAdshead committed Jul 16, 2020
1 parent 6229d4a commit 940eb66
Show file tree
Hide file tree
Showing 5 changed files with 1,113 additions and 139 deletions.
27 changes: 27 additions & 0 deletions __tests__/unicorn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2017 American Express Travel Related Services Company, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

describe('unicorn.js', () => {
it('should be import/require-able', () => {
let configImportable = true;
try {
// require is part of the test
require('../unicorn'); // eslint-disable-line global-require
} catch (error) {
configImportable = false;
}

expect(configImportable).toBe(true);
});
});
35 changes: 1 addition & 34 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ module.exports = {
},
extends: [
'eslint-config-airbnb',
'./unicorn',
].map(require.resolve).concat([
// Helpful rules for writing React
'plugin:react/recommended',
// Some helpful rules that will prevent bugs
'plugin:unicorn/recommended',
// Use native JS instead of lodash
'plugin:you-dont-need-lodash-underscore/compatible',
]),
Expand All @@ -57,7 +56,6 @@ module.exports = {
'jsx-a11y',
'markdown',
'react',
'unicorn',
'react-hooks',
'you-dont-need-lodash-underscore',
],
Expand Down Expand Up @@ -143,37 +141,6 @@ module.exports = {
'no-restricted-modules': ['error', { paths: forbiddenModules }],
'no-restricted-imports': ['error', { paths: forbiddenModules }],

// We shouldn't enforce filename casing to always be the same. e.g. We may
// prefer kebab-case for bin files, PascalCase for React components, etc.
'unicorn/filename-case': 'off',

// Uses safe-regex to disallow potentially catastrophic exponential-time
// regular expressions.
'unicorn/no-unsafe-regex': 'error',

// Impacts common pattern of returning anonymous function
// Performance claim based off single stackoverflow thread
// https://stackoverflow.com/questions/80802/does-use-of-anonymous-functions-affect-performance/81329#81329
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/consistent-function-scoping.md
'unicorn/consistent-function-scoping': 'off',

// Preventing abbreviations is incompatible with React standards (props, ref, etc.)
// Additionally, there are many popular libraries that have abbreviations
// as their standard practice and this rule prevents that consistency
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prevent-abbreviations.md
'unicorn/prevent-abbreviations': 'off',

// Array.includes() is consistent with String.includes()
// the rule's performance claim is unsubstantiated and appears to be premature optimization
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/495 and
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/604
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-set-has.md
'unicorn/prefer-set-has': 'off',

// This rule is incompatible with React where null must be returned
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-null.md
'unicorn/no-null': 'off',

// Functions that take many positional arguments can be difficult to work
// with and produce less maintainable APIs. When more than three arguments
// are needed, named arguments should be used.
Expand Down
Loading

0 comments on commit 940eb66

Please # to comment.