Skip to content

Commit

Permalink
Update build and test pipelines (moroshko#729)
Browse files Browse the repository at this point in the history
* update build and test pipelines

* fix jsdom version for tests

* move deps to devDependencies

* update nyc

* update lint-staged and husky

* update sinon

* update lint-staged file pattern

* update prettier

* update easy dependencies
  • Loading branch information
aberezkin authored Mar 29, 2020
1 parent 2af30e4 commit 0ae7828
Show file tree
Hide file tree
Showing 30 changed files with 10,452 additions and 6,312 deletions.
15 changes: 10 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"presets": ["@babel/env", "@babel/preset-react"],
"plugins": [
"@babel/plugin-proposal-class-properties"
],
"env": {
"development": {
"presets": ["es2015", "stage-0", "react"]
},
"production": {
"presets": ["es2015", "stage-0", "react"],
"plugins": [
[
"transform-react-remove-prop-types", {
"babel-plugin-transform-react-remove-prop-types", {
"mode": "wrap"
}
]
]
},
"test": {
"plugins": [
"istanbul",
]
}
}
}
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ module.exports = {
],
'no-template-curly-in-string': 2,
'no-unused-vars': 2,
'newline-after-var': [2, 'always'],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var']
}
],
'prefer-destructuring': [2, { array: false, object: true }],
'prefer-rest-params': 2,

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ demo/dist
npm-debug.log
yarn.lock
*.log
.DS
3 changes: 3 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require: '@babel/register'
file:
- ./test/setup.js
2 changes: 1 addition & 1 deletion demo/src/components/App/components/Examples/Examples.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/App/components/Features/Features.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

@vertical: ~"(max-width: 859px)";

Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/App/components/Footer/Footer.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/App/components/Header/Header.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~variables';
@import 'variables';

.container {
position: relative;
Expand Down
223 changes: 2 additions & 221 deletions demo/standalone/compiled.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,229 +41,10 @@
/******/ [
/* 0 */
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);

/***/
},
/* 1 */
/***/ function(module, exports) {
'use strict';

var _createClass = (function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
(function webpackMissingModule() {
throw new Error('Cannot find module "./demo/standalone/app"');
})();

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}

function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called"
);
}
return call && (typeof call === 'object' || typeof call === 'function')
? call
: self;
}

function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError(
'Super expression must either be null or a function, not ' +
typeof superClass
);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass)
Object.setPrototypeOf
? Object.setPrototypeOf(subClass, superClass)
: (subClass.__proto__ = superClass);
}

/* eslint-disable react/react-in-jsx-scope */

var languages = [
{
name: 'C',
year: 1972
},
{
name: 'C#',
year: 2000
},
{
name: 'C++',
year: 1983
},
{
name: 'Clojure',
year: 2007
},
{
name: 'Elm',
year: 2012
},
{
name: 'Go',
year: 2009
},
{
name: 'Haskell',
year: 1990
},
{
name: 'Java',
year: 1995
},
{
name: 'JavaScript',
year: 1995
},
{
name: 'Perl',
year: 1987
},
{
name: 'PHP',
year: 1995
},
{
name: 'Python',
year: 1991
},
{
name: 'Ruby',
year: 1995
},
{
name: 'Scala',
year: 2003
}
];

// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Using_special_characters
var escapeRegexCharacters = function escapeRegexCharacters(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
};

var getSuggestions = function getSuggestions(value) {
var escapedValue = escapeRegexCharacters(value.trim());

if (escapedValue === '') {
return [];
}

var regex = new RegExp('^' + escapedValue, 'i');

return languages.filter(function(language) {
return regex.test(language.name);
});
};

var getSuggestionValue = function getSuggestionValue(suggestion) {
return suggestion.name;
};

var renderSuggestion = function renderSuggestion(suggestion) {
return React.createElement('span', null, suggestion.name);
};

// prettier-ignore

var App = function (_React$Component) {
_inherits(App, _React$Component);

// eslint-disable-line no-undef
function App() {
_classCallCheck(this, App);

var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this));

_this.onChange = function (event, _ref) {
var newValue = _ref.newValue;

_this.setState({
value: newValue
});
};

_this.onSuggestionsFetchRequested = function (_ref2) {
var value = _ref2.value;

_this.setState({
suggestions: getSuggestions(value)
});
};

_this.onSuggestionsClearRequested = function () {
_this.setState({
suggestions: []
});
};

_this.state = {
value: '',
suggestions: getSuggestions('')
};
return _this;
}

_createClass(App, [{
key: 'render',
value: function render() {
var _state = this.state,
value = _state.value,
suggestions = _state.suggestions;

var inputProps = {
placeholder: "Type 'c'",
value: value,
onChange: this.onChange
};

return React.createElement(Autosuggest // eslint-disable-line react/jsx-no-undef
, { suggestions: suggestions,
onSuggestionsFetchRequested: this.onSuggestionsFetchRequested,
onSuggestionsClearRequested: this.onSuggestionsClearRequested,
getSuggestionValue: getSuggestionValue,
renderSuggestion: renderSuggestion,
inputProps: inputProps
});
}
}]);

return App;
}(React.Component);

ReactDOM.render(
React.createElement(App, null),
document.getElementById('app')
); // eslint-disable-line no-undef

/***/
}
/******/
Expand Down
14 changes: 14 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const babelConfig = require('@istanbuljs/nyc-config-babel');

module.exports = {
...babelConfig,
statements: 95,
branches: 91,
functions: 100,
lines: 95,
include: ['src/*.js'],
exclude: ['test/**/*.js'],
reporter: ['lcov', 'text-summary'],
all: true,
'check-coverage': true
};
Loading

0 comments on commit 0ae7828

Please sign in to comment.