This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from adambrgmn/develop
Update Eslint config
- Loading branch information
Showing
5 changed files
with
88 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": ["./src/config/eslintrc.js"], | ||
"rules": { | ||
"global-require": "off", | ||
"no-process-exit": "off", | ||
"import/no-dynamic-require": "off", | ||
"import/no-unassigned-import": "off", | ||
"no-console": "off", | ||
"no-nested-ternary": "off" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CLIEngine } from 'eslint'; | ||
import baseConfig from '../eslintrc'; | ||
|
||
jest.mock('../../utils', () => ({ | ||
...require.requireActual('../../utils'), | ||
ifAnyDep: jest.fn((key, t) => t), | ||
})); | ||
|
||
const cli = new CLIEngine({ | ||
useEslintrc: false, | ||
baseConfig, | ||
}); | ||
|
||
const lint = code => { | ||
const linter = cli.executeOnText(code); | ||
return linter.results[0]; | ||
}; | ||
|
||
afterEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
test('Understands class properties', () => { | ||
const result = lint(` | ||
export class Bar { | ||
constructor() { | ||
this.bar = 'foo'; | ||
} | ||
setFoo = f => { | ||
this.foo = f; | ||
} | ||
getFoo(){ | ||
return this.bar; | ||
} | ||
} | ||
`); | ||
|
||
const filtered = result.messages.filter(m => m.fatal); | ||
expect(filtered.length).toBeLessThan(1); | ||
}); | ||
|
||
test('Understands jsx', () => { | ||
const result = lint(` | ||
/* eslint-disable react/prop-types, react/react-in-jsx-scope */ | ||
export const Comp = ({ children, ...rest }) => ( | ||
<button {...rest}>{children}</button> | ||
); | ||
`); | ||
|
||
expect(result.errorCount).toBeLessThan(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,10 +1,30 @@ | ||
const { ifAnyDep } = require('../utils'); | ||
|
||
module.exports = { | ||
parser: 'babel-eslint', | ||
extends: [ | ||
require.resolve('eslint-config-airbnb-base'), | ||
ifAnyDep('react', require.resolve('eslint-config-airbnb')), | ||
require.resolve('eslint-config-prettier'), | ||
].filter(Boolean), | ||
rules: {}, | ||
plugins: ['babel'], | ||
env: { | ||
browser: true, | ||
node: true, | ||
commonjs: true, | ||
'shared-node-browser': true, | ||
es6: true, | ||
worker: true, | ||
jest: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
}, | ||
rules: { | ||
'import/prefer-default-export': 'off', | ||
'react/jsx-filename-extension': 'off', | ||
'react/sort-comp': 'off', | ||
}, | ||
}; |
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