Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Commit

Permalink
add new rules
Browse files Browse the repository at this point in the history
enable semi on babel plugin

default enable unit-test rules for all preset

default enable babel rules for react preset

remove webextensions global variable support as we use mozilla/webextension-polyfill now

only allow jsx on .js file because of facebook/create-react-app#87 (comment)
-234627904
  • Loading branch information
foray1010 committed Jan 30, 2018
1 parent b3e4839 commit 76093aa
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 328 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
const extendsConfig = require('./lib/extendsConfig')

module.exports = extendsConfig({
extends: ['eslint-config-airbnb/base', 'eslint-config-foray1010/rules/main'],
extends: [
'eslint-config-airbnb/base',
'eslint-config-foray1010/rules/main',
'eslint-config-foray1010/rules/unit-test'
],
parserOptions: {
ecmaFeatures: {
// if you want to use jsx, extends "foray1010/react"
Expand Down
18 changes: 17 additions & 1 deletion react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ module.exports = extendsConfig({
extends: [
'eslint-config-airbnb',
'eslint-config-foray1010/rules/main',
'eslint-config-foray1010/rules/frontend'
'eslint-config-foray1010/rules/frontend',
'eslint-config-foray1010/rules/babel',
'eslint-config-foray1010/rules/unit-test'
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.json']
}
},
'import/extensions': ['.js'],
react: {
pragma: 'createElement'
}
Expand All @@ -35,6 +43,14 @@ module.exports = extendsConfig({
}
],

// do not use .jsx because of https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': [
'error',
{
extensions: ['.js']
}
],

// ignorePureComponents because PureComponents helps improving performance and
// make the flow easier to understand
'react/prefer-stateless-function': [
Expand Down
4 changes: 2 additions & 2 deletions rules/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const mainRules = extendsConfig({
// as these rules do not work with babel-eslint
// using eslint-plugin-babel to deal with these rules
const migratedRules = {}
const migrateRuleNames = ['new-cap', 'no-invalid-this', 'object-curly-spacing']
const migrateRuleNames = ['new-cap', 'no-invalid-this', 'object-curly-spacing', 'semi']
for (const migrateRuleName of migrateRuleNames) {
migratedRules[migrateRuleName] = 'off'
migratedRules[`babel/${migrateRuleName}`] = mainRules.rules[migrateRuleName]
}

module.exports = {
parser: 'babel-eslint',
plugins: ['babel'],
plugins: ['eslint-plugin-babel'],
rules: migratedRules
}
3 changes: 0 additions & 3 deletions rules/frontend.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict'

module.exports = {
env: {
webextensions: true
},
globals: {
document: false,
window: false
Expand Down
Loading

0 comments on commit 76093aa

Please sign in to comment.