Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Clean up & simplify the project (#26)
Browse files Browse the repository at this point in the history
* Update ESLint and Babel config

- ESLint: use babel-eslint parser for parity with Babel-supported syntax
- Babel: use the minimal set of plugins for successful code compilation

* Use the latest version of Yarn for Travis CI builds

* Use our Cosmos config together with react-cosmos-test/enzyme
  • Loading branch information
vojtechszocs authored and rawagner committed Sep 25, 2018
1 parent fae92e7 commit 24bf17d
Show file tree
Hide file tree
Showing 55 changed files with 3,214 additions and 5,217 deletions.
13 changes: 13 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://github.com/browserslist/browserslist

# include browsers based on global coverage
> 1%

# exclude all Internet Explorer versions
not ie > 0

# include browsers we are committed to support
last 1 Chrome version
last 1 Firefox version
last 1 Edge version
last 1 Safari version
17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

33 changes: 12 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# https://git-scm.com/docs/gitignore

# dependencies
/node_modules
# files generated by package manager
/node_modules/
/yarn-debug.log
/yarn-error.log

# testing
/coverage

# production
/dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea
# build artifacts and other generated files
/dist/
/coverage/
/cosmos/

# editor files
/.idea/
/.vscode/
18 changes: 0 additions & 18 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"trailingComma": "none",
"printWidth": 120
}
4 changes: 0 additions & 4 deletions .stylelintrc

This file was deleted.

12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
language: node_js
node_js:
- '10'
- 'lts/*'
cache: yarn
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- yarn install
script:
- yarn test
- yarn coveralls
- yarn dist

- yarn build
- yarn coveralls
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

# web-ui-components
Set of reusable components identified during [kubevirt/web-ui](https://github.com/kubevirt/web-ui) development.

6 changes: 6 additions & 0 deletions config/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://babeljs.io/docs/en/next/options

module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties']
};
24 changes: 24 additions & 0 deletions config/cosmos.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// https://github.com/react-cosmos/react-cosmos#config

const paths = require('./paths');

module.exports = {
rootPath: paths.projectRoot,

// by convention, all fixtures use the '.fixture.js' suffix
fileMatch: '**/*.fixture.js',

// additional modules to load along with every component
globalImports: ['@babel/polyfill'],

// path to Cosmos proxies
proxiesPath: `${paths.src}/cosmos/proxies.js`,

// webpack server settings
webpackConfigPath: `${paths.config}/cosmos.webpack.config.js`,
watchDirs: [paths.src],
port: 9000,

// directory where cosmos-export tool generates the static application
outputPath: paths.cosmosExport
};
23 changes: 23 additions & 0 deletions config/cosmos.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// https://webpack.js.org/configuration/

const chalk = require('chalk');
const paths = require('./paths');
const babelOptions = require('./babel.config');

const webpackMode = process.env.NODE_ENV === 'production' ? 'production' : 'development';
console.log(chalk`Running webpack in {white ${webpackMode}} mode.`);

module.exports = {
mode: webpackMode,

module: {
rules: [
{
test: /\.js$/,
include: paths.src,
loader: 'babel-loader',
options: babelOptions
}
]
}
};
93 changes: 0 additions & 93 deletions config/env.js

This file was deleted.

55 changes: 55 additions & 0 deletions config/eslint.browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// https://eslint.org/docs/user-guide/configuring
// This configuration covers code meant to execute in browser or browser-like environment.

const chalk = require('chalk');
const paths = require('./paths');
const pkg = require(paths.packageJson);

// resolve React version for use with eslint-plugin-react
const reactVersion = /^\D*(\d+).*$/.exec(pkg.peerDependencies.react)[1];
console.log(chalk`Using React {white ${reactVersion}} linting rules.`);

const commonRules = require('./eslint.rules.common');
const reactRules = require('./eslint.rules.react');

module.exports = {
extends: [
'standard',
'standard-react',
'airbnb',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:promise/recommended',
'plugin:jest/recommended',
// Prettier configuration comes last
'plugin:prettier/recommended',
'prettier/react',
'prettier/standard'
],

env: {
es6: true,
browser: true,
jest: true
},

// use babel-eslint parser to ensure parity with Babel-supported syntax
parser: 'babel-eslint',

settings: {
react: {
version: reactVersion
}
},

rules: {
...commonRules,
...reactRules,
'react/destructuring-assignment': [
'error',
{
ignoreClassFields: true
}
]
}
};
35 changes: 35 additions & 0 deletions config/eslint.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// https://eslint.org/docs/user-guide/configuring
// This configuration covers code meant to execute in Node.js environment.

const commonRules = require('./eslint.rules.common');

module.exports = {
extends: [
'standard',
'airbnb',
'plugin:node/recommended',
'plugin:jest/recommended',
// Prettier configuration comes last
'plugin:prettier/recommended',
'prettier/standard'
],

env: {
es6: true,
node: true,
jest: true
},

parserOptions: {
// Node.js loads scripts as CommonJS modules
sourceType: 'script'
},

rules: {
...commonRules,
'no-console': 'off',
'global-require': 'off',
'import/no-dynamic-require': 'off',
'import/newline-after-import': 'off'
}
};
33 changes: 33 additions & 0 deletions config/eslint.rules.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Common ESLint rule configuration extracted from patternfly-react/recommended.

module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true
}
],
'import/no-named-default': 'off',
'import/prefer-default-export': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-prototype-builtins': 'off',
'no-restricted-syntax': 'off',
'no-underscore-dangle': 'off',
'no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true
}
],
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'none',
ignoreRestSiblings: true
}
],
'no-use-before-define': 'off'
};

0 comments on commit 24bf17d

Please sign in to comment.