Skip to content

Commit

Permalink
add eslint + prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Jan 24, 2019
1 parent 9fc98a7 commit a4e0c9e
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
__tests__/fixtures/
71 changes: 71 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const OFF = 0;
const WARN = 1;
const ERROR = 2;

module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
ecmaFeatures: {
jsx: false,
experimentalObjectRestSpread: true,
},
},
root: true, // stop ESLint from looking for a configuration file in parent folders
env: {
es6: true,
jest: true,
node: true,
},

extends: ['@kiwicom/eslint-config'],

rules: {
'no-process-env': ERROR,
'no-restricted-imports': [
ERROR,
{
paths: [
{
name: 'graphql-relay',
// TODO: eventually just disallow it completely
importNames: [
'fromGlobalId', // @kiwicom/graphql-global-id
'toGlobalId',
'connectionArgs', // @kiwicom/graphql-utils
'connectionDefinitions',
'connectionFromArray',
'connectionFromArraySlice',
'connectionFromPromisedArray',
'connectionFromPromisedArraySlice',
],
},
],
},
],
'import/no-extraneous-dependencies': [
ERROR,
{
devDependencies: ['/scripts/**', '**/*.test.js', '**/*.spec.js'],
},
],
'dependencies/no-cycles': OFF, // cycles are sometimes expected in GraphQL

// Possible future of @kiwicom/eslint-config:
'jest/prefer-to-be-null': ERROR,
'jest/prefer-to-be-undefined': ERROR,
'jest/prefer-to-contain': ERROR,
'jest/prefer-to-have-length': ERROR,
},

overrides: [
{
files: ['scripts/**/*.js', 'src/packages/**/*.js'],
rules: {
// It's expected to access process.env in our NPM packages or scrips.
'no-process-env': OFF,
},
},
],
};
9 changes: 9 additions & 0 deletions jest-eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

module.exports = {
displayName: 'lint',
verbose: false,
reporters: ['default'],
runner: './src/packages/eslint-config-kiwicom/eslint-runner/index.js',
testMatch: ['<rootDir>/src/**/*.js', '<rootDir>/scripts/**/*.js'],
};
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
"name": "osmcz-v2",
"scripts": {
"dev": "next ./src",
"lint": "eslint --print-config . | eslint-config-prettier-check && eslint . --report-unused-disable-directives",
"build": "next build ./src",
"start": "next start ./src"
},
"dependencies": {
"next": "^7.0.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"@kiwicom/eslint-config": "^2.1.0",
"eslint": "^5.12.1",
"eslint-plugin-jsx-a11y": "^6.1.2",
"babel-plugin-styled-components": "^1.10.0",
"babel-eslint": "^10.0.1"
}
}
12 changes: 7 additions & 5 deletions src/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow

module.exports = {
webpack: config => {
// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty'
}
fs: 'empty',
};

return config
}
}
return config;
},
};
11 changes: 5 additions & 6 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
// @flow

const Home = () => (
<div>
</div>
)
import React from 'react';

export default Home
const Home = () => <div />;

export default Home;

0 comments on commit a4e0c9e

Please sign in to comment.