-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
16,421 additions
and
5,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
extends: ['./index.js', 'prettier'], | ||
extends: ['./index.js'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
14.17.4 | ||
16.13.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,47 @@ | ||
// This is a workaround for: https://github.com/eslint/eslint/issues/3458 | ||
require('@rushstack/eslint-patch/modern-module-resolution'); | ||
|
||
const dotProp = require('dot-prop'); | ||
const findUp = require('find-up'); | ||
const readPkgUp = require('read-pkg-up'); | ||
const semver = require('semver'); | ||
const {mergeAndConcat} = require('merge-anything'); | ||
|
||
const babel = require('./src/babel'); | ||
const electron = require('./src/electron'); | ||
const eslint = require('./src/eslint'); | ||
const eslintComments = require('./src/eslint-comments'); | ||
const comments = require('./src/comments'); | ||
const getOffMyLawn = require('./src/get-off-my-lawn'); | ||
const imprt = require('./src/import'); | ||
const json = require('./src/json'); | ||
const jsxA11y = require('./src/jsx-a11y'); | ||
const jest = require('./src/jest'); | ||
const json = require('./src/json'); | ||
const next = require('./src/next'); | ||
const node = require('./src/node'); | ||
const objects = require('./src/objects'); | ||
const prettier = require('./src/prettier'); | ||
const react = require('./src/react'); | ||
const reactHooks = require('./src/react-hooks'); | ||
const reactNative = require('./src/react-native'); | ||
const security = require('./src/security'); | ||
const typescript = require('./src/typescript'); | ||
const unicorn = require('./src/unicorn'); | ||
|
||
const pkg = readPkgUp.sync() || {}; | ||
|
||
const packageJsonContains = (dependency) => | ||
dotProp.get(pkg, `packageJson.dependencies.${dependency}`) || | ||
dotProp.get(pkg, `packageJson.devDependencies.${dependency}`); | ||
|
||
const usesBabelConfig = findUp.sync(['.babelrc', '.babelrc.json', 'babel.config.json']); | ||
const usesElectron = packageJsonContains('electron'); | ||
const usesJest = packageJsonContains('jest'); | ||
const usesNext = packageJsonContains('next'); | ||
const usesPrettier = packageJsonContains('prettier'); | ||
const usesReact = packageJsonContains('react'); | ||
const usesReactNative = packageJsonContains('react-native'); | ||
const reactVersion = usesReact ? semver.coerce(usesReact).version : undefined; | ||
|
||
const config = { | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es2021: true, | ||
node: true, | ||
'shared-node-browser': true, | ||
}, | ||
parser: '@babel/eslint-parser', | ||
parserOptions: { | ||
allowImportExportEverywhere: true, | ||
ecmaVersion: 2021, | ||
requireConfigFile: false, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['eslint-comments', 'get-off-my-lawn', 'import', 'json', 'node', 'objects', 'security', 'unicorn'], | ||
reportUnusedDisableDirectives: true, | ||
rules: { | ||
...eslint, | ||
...eslintComments, | ||
...getOffMyLawn, | ||
...imprt, | ||
...json, | ||
...node, | ||
...objects, | ||
...security, | ||
...unicorn, | ||
}, | ||
}; | ||
|
||
if (usesElectron) { | ||
dotProp.set(config, 'settings.node.allowModules', ['electron']); | ||
} | ||
|
||
if (usesJest) { | ||
dotProp.set(config, 'env.jasmine', true); | ||
dotProp.set(config, 'env.jest', true); | ||
config.plugins.push('jest'); | ||
config.rules = { | ||
...config.rules, | ||
...jest, | ||
}; | ||
} | ||
|
||
if (usesReact) { | ||
dotProp.set(config, 'parserOptions.ecmaFeatures.jsx', true); | ||
dotProp.set(config, 'settings.react.version', 'detect'); | ||
config.plugins.push('react'); | ||
config.rules = { | ||
...config.rules, | ||
...react, | ||
}; | ||
|
||
if (semver.gte(reactVersion, '16.8.0')) { | ||
config.plugins.push('react-hooks'); | ||
config.rules = { | ||
...config.rules, | ||
...reactHooks, | ||
}; | ||
} | ||
|
||
if (usesReactNative) { | ||
dotProp.set(config, 'env.react-native/react-native', true); | ||
config.plugins.push('react-native'); | ||
config.rules = { | ||
...config.rules, | ||
...reactNative, | ||
}; | ||
} else { | ||
config.plugins.push('jsx-a11y'); | ||
config.rules = { | ||
...config.rules, | ||
...jsxA11y, | ||
}; | ||
} | ||
} | ||
|
||
if (usesBabelConfig) { | ||
dotProp.set(config, 'parserOptions.babelOptions.configFile', usesBabelConfig); | ||
dotProp.set(config, 'parserOptions.requireConfigFile', true); | ||
} else if (usesNext) { | ||
dotProp.set(config, 'parserOptions.babelOptions.presets', ['next/babel']); | ||
} else if (usesReact) { | ||
dotProp.set(config, 'parserOptions.babelOptions.presets', ['@babel/preset-react']); | ||
} | ||
|
||
if (usesPrettier) { | ||
config.rules = { | ||
...config.rules, | ||
...require('eslint-config-prettier').rules, | ||
}; | ||
} | ||
const config = mergeAndConcat( | ||
// Order of these doesn't matter. | ||
comments, | ||
babel, | ||
electron, | ||
eslint, | ||
getOffMyLawn, | ||
imprt, | ||
jest, | ||
json, | ||
next, | ||
node, | ||
objects, | ||
react, | ||
reactNative, | ||
security, | ||
unicorn, | ||
// These need to be listed last, and in this order, to override | ||
// or modify rules in the various configs above, as needed. | ||
typescript, | ||
prettier | ||
); | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
module.exports = { | ||
coverageDirectory: '.coverage', | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
}; |
Oops, something went wrong.