Skip to content

Commit

Permalink
Add Node and Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bradshaw committed Jun 12, 2020
1 parent 6fa4275 commit 089e7f4
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ If the project includes Babel, then [eslint-plugin-babel]() will be loaded and t

### Compat

[TODO] If no transpiler is detected and `env.browser = true` in your `.eslintrc`, then [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) is loaded.
If no transpiler is detected and `env.browser = true` in your `.eslintrc`, then [eslint-plugin-compat](https://github.com/amilajack/eslint-plugin-compat) is loaded.

### Node

[TODO] If `env.node = true` in your `.eslintrc` file, then [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) is loaded.
If `env.node = true` in your `.eslintrc` file, then [eslint-plugin-node](https://github.com/mysticatea/eslint-plugin-node) is loaded.

### React

Expand Down
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ const showLoaded = require('./lib/loaded')
const { hasAnyDep } = require('./lib/utils')

const { configs } = require('./configs')
const plugins = require('./plugins')

const plugins = []

const hasBabel = hasAnyDep('babel')
const hasReact = hasAnyDep('react')
const hasTypescript = hasAnyDep('typescript')

if (hasBabel || hasAnyDep('@babel/core')) plugins.push('babel')

const airbnbDependentcies = ['import']
if (hasReact) airbnbDependentcies.push('jsx-a11y', 'react', 'react-hooks')

Expand Down
32 changes: 1 addition & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,8 @@
"rimraf": "^3.0.2"
},
"devDependencies": {
"babel": "^6.23.0",
"eslint": "^7.2.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-find-rules": "^3.5.0",
"eslint-plugin-array-func": "^3.1.6",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-json": "^2.1.1",
"eslint-plugin-json-format": "^2.0.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-lodash": "^7.1.0",
"eslint-plugin-lodash-fp": "^2.2.0-a1",
"eslint-plugin-markdown": "^1.0.2",
"eslint-plugin-no-constructor-bind": "^2.0.0",
"eslint-plugin-no-secrets": "^0.6.8",
"eslint-plugin-no-unsanitized": "^3.1.2",
"eslint-plugin-no-use-extend-native": "^0.5.0",
"eslint-plugin-optimize-regex": "^1.2.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-ramda": "^2.5.1",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-scanjs-rules": "^0.2.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-simple-import-sort": "^5.0.3",
"eslint-plugin-sonarjs": "^0.5.0",
"eslint-plugin-switch-case": "^1.1.2",
"eslint-plugin-unicorn": "^20.1.0",
"husky": "^4.2.5",
"in-publish": "^2.0.1",
"prettier": "^2.0.5",
Expand All @@ -78,6 +48,6 @@
"safe-publish-latest": "^1.1.4"
},
"engines": {
"node": ">= 8"
"node": ">= 8.3"
}
}
18 changes: 18 additions & 0 deletions plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { cosmiconfigSync } = require('cosmiconfig')

const { hasAnyDep } = require('./lib/utils')

const explorerSync = cosmiconfigSync('eslint')
const eslintrc = explorerSync.search()
const { env } = eslintrc.config

const hasBabel = hasAnyDep('babel') || hasAnyDep('@babel/core')

const plugins = []

if (hasBabel) plugins.push('babel')
if (env.node) plugins.push('node')

if (env.browser && !hasBabel && !hasAnyDep('typescript')) plugins.push('compat')

module.exports = plugins
6 changes: 6 additions & 0 deletions rules/compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line no-console
console.log(' eslint-plugin-compat')

module.exports = {
extends: ['plugin:compat/recommended'],
}
6 changes: 6 additions & 0 deletions rules/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line no-console
console.log(' eslint-plugin-node')

module.exports = {
extends: ['plugin:node/recommended'],
}

0 comments on commit 089e7f4

Please # to comment.