Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Typescript #256

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 13 additions & 264 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,267 +1,16 @@
// Apply best practices by enabling eslint:recommended
// Never repeat rules that eslint:recommended sets as a default
// Explicitly add more rules categorized in categories taken from official docs

module.exports = {
'extends': 'eslint:recommended',
'parserOptions': {
"ecmaVersion": 2017,
'sourceType': 'module',
'ecmaFeatures': {
'experimentalObjectRestSpread': true,
'jsx': true,
'impliedStrict': true
}
},
'env': {
'browser': true,
'commonjs': true,
'es6': true,
'node': true,
'jquery': true,
'serviceworker': true
},
'rules': {
// Possible Errors
'no-console': 1,
'no-template-curly-in-string': 2,

// Best Practices
'array-callback-return': 2,
'block-scoped-var': 2,
'consistent-return': 2,
'curly': 2,
'default-case': 2,
'dot-notation': 2,
'eqeqeq': [
2,
'smart'
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
env: {
browser: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
'no-alert': 1,
'no-caller': 2,
'no-div-regex': 2,
'no-else-return': 2,
'no-eq-null': 2,
'no-eval': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-label': 2,
'no-floating-decimal': 2,
'no-global-assign': 2,
'no-implied-eval': 2,
'no-lone-blocks': 2,
'no-loop-func': 2,
'no-multi-spaces': 2,
'no-proto': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-unused-expressions': 2,
'no-useless-call': 2,
'no-useless-concat': 2,
'no-useless-escape': 2,
'no-void': 2,
'no-with': 2,
'radix': 2,
'wrap-iife': [
2,
'inside'
],
'yoda': [
2,
'never'
],

// Strict Mode
'strict': 2,

// Variables
'init-declarations': [
2,
'always'
],
'no-label-var': 2,
'no-undef-init': 2,
'no-undefined': 2,
'no-use-before-define': 2,

// Stylistic Issues
'array-bracket-spacing': [
1,
'never'
],
'block-spacing': [
2,
'always'
],
'brace-style': [
2,
'stroustrup',
{
'allowSingleLine': true
}
],
'camelcase': 2,
'comma-dangle': [
2,
'only-multiline'
],
'comma-spacing': [
2,
{
'before': false,
'after': true
}
],
'comma-style': [
2,
'last'
],
'computed-property-spacing': [
2,
'never'
],
'eol-last': 2,
'func-call-spacing': [
2,
'never'
],
'func-names': [
1,
'always'
],
'indent': [
2,
2
],
'jsx-quotes': [
2,
'prefer-double'
],
'key-spacing': [
2,
{
'beforeColon': false,
'afterColon': true
}
],
'keyword-spacing': 2,
'line-comment-position': [
2,
{
'position': 'above'
}
],
'linebreak-style': [
2,
'unix'
],
'lines-around-directive': [
2,
'always'
],
'max-depth': 2,
'new-cap': 2,
'new-parens': 2,
'no-lonely-if': 2,
'no-nested-ternary': 2,
'no-tabs': 2,
'no-trailing-spaces': 2,
'no-underscore-dangle': 2,
'no-unneeded-ternary': 2,
'no-whitespace-before-property': 2,
'object-curly-spacing': [
2,
'always'
],
'object-property-newline': 2,
'one-var-declaration-per-line': [
2,
'always'
],
'one-var': [
2,
'never'
],
'operator-assignment': [
2,
'always'
],
'quote-props': [
2,
'as-needed'
],
'quotes': [
2,
'single'
],
'semi-spacing': [
2,
{
'before': false,
'after': true
}
],
'semi': [
2,
'always'
],
'space-before-blocks': 2,
'space-before-function-paren': [
2,
'never'
],
'space-in-parens': [
2,
'never'
],
'space-infix-ops': 2,
'space-unary-ops': [
2,
{
'words': true,
'nonwords': false
}
],
'spaced-comment': [
2,
'always'
],

// ECMAScript 6
'arrow-parens': [
2,
'as-needed'
],
'arrow-spacing': [
2,
{
'before': true,
'after': true
}
],
'generator-star-spacing': [
2,
{
'before': false,
'after': true
}
],
'no-confusing-arrow': 2,
'no-const-assign': 2,
'no-duplicate-imports': 2,
'no-restricted-imports': 2,
'no-this-before-super': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-rename': 2,
'no-var': 2,
'prefer-arrow-callback': 2,
'prefer-const': 2,
'prefer-template': 2,
'require-yield': 2,
'template-curly-spacing': [
2,
'never'
],
}
};
18 changes: 18 additions & 0 deletions config/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var path = require('path');
var _root = path.resolve(__dirname, '..');

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}

exports.root = root;

function isVendor(module, count) {
if (typeof module.context !== 'string') {
return false;
}
return module.context.indexOf('/node_modules/') >= 0
}

exports.isVendor = isVendor;
53 changes: 53 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
var webpack = require('webpack');

var helpers = require('./helpers');

const ENV = process.env.NODE_ENV = process.env.ENV = 'development';

module.exports = (env, argv) => {

// Set ENV depending on wepack mode (contained in argv passed by webpack --mode)
const ENV = process.env.NODE_ENV = process.env.ENV = (argv.mode === 'development') ? 'development' : 'production';

return {
output: {
path: helpers.root('dist'),
filename: '[name].js',
libraryTarget: 'umd',
library: '[name]',
umdNamedDefine: true,
globalObject: `(typeof self !== 'undefined' ? self : this)`

},

entry: {
'siema': helpers.root('src', 'siema.ts')
},

devtool: ENV === 'development' ? 'eval-cheap-module-source-map': 'source-map',

resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'awesome-typescript-loader',
options: { configFileName: helpers.root('tsconfig.json') }
}
]
}
]

},

optimization: {
minimize: true
}

}

}
Loading