Skip to content

Commit

Permalink
Convert entry module to typescript and set up tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Apr 6, 2018
1 parent 8ae4b80 commit d9e7aa6
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 24 deletions.
26 changes: 26 additions & 0 deletions .tslint.js
@@ -0,0 +1,26 @@
module.exports = {
defaultSeverity: 'error',
extends: 'tslint-config-standard',
linterOptions: {
exclude: [
'./build/*',
'./es5/**/*',
'./dev/**/*',
'./src/stylus/*.styl',
'./src/util/testing.js',
'./src/util/to-have-been-warned.js',
'**/*.spec.js',
'./node_modules/**/*'
]
},
jsRules: {
'max-line-length': [true, 140],
'no-debugger': process.env.NODE_ENV === 'production'
},
rules: {
'max-line-length': [true, 140],
'no-debugger': process.env.NODE_ENV === 'production',
'strict-type-predicates': false
},
rulesDirectory: []
}
2 changes: 1 addition & 1 deletion build/webpack.base.config.js
Expand Up @@ -4,7 +4,7 @@ const resolve = file => require('path').resolve(__dirname, file)

module.exports = {
resolve: {
extensions: ['*', '.js', '.json', '.vue'],
extensions: ['*', '.js', '.json', '.vue', '.ts'],
alias: {
'@': resolve('../src')
}
Expand Down
18 changes: 15 additions & 3 deletions build/webpack.dev.config.js
Expand Up @@ -27,7 +27,7 @@ module.exports = merge(baseWebpackConfig, {
library: 'Vuetify'
},
resolve: {
extensions: ['*', '.js', '.json', '.vue'],
extensions: ['*', '.js', '.json', '.vue', '.ts'],
alias: {
vuetify: resolve('../src'),
'vue$': 'vue/dist/vue.esm.js'
Expand All @@ -49,8 +49,20 @@ module.exports = merge(baseWebpackConfig, {
exclude: /node_modules/
},
{
test: /\.js$/,
loaders: ['babel-loader', 'eslint-loader'],
test: /\.[jt]s$/,
enforce: 'pre',
loader: 'tslint-loader',
options: {
failOnHint: true,
typeCheck: true,
configFile: resolve('../.tslint.js'),
tsConfigFile: resolve('../tsconfig.json')
},
exclude: /node_modules/
},
{
test: /\.[jt]s$/,
loaders: ['babel-loader', 'ts-loader'],
exclude: /node_modules/
},
{
Expand Down
27 changes: 12 additions & 15 deletions build/webpack.prod.config.js
Expand Up @@ -17,7 +17,7 @@ const resolve = file => require('path').resolve(__dirname, file)

module.exports = merge(baseWebpackConfig, {
entry: {
app: './src/index.js'
app: './src/index.ts'
},
output: {
path: resolve('../dist'),
Expand All @@ -30,23 +30,20 @@ module.exports = merge(baseWebpackConfig, {
noParse: /es6-promise\.js$/, // avoid webpack shimming process
rules: [
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
loaders: {
stylus: extractPlugin
}
}
},
'eslint-loader'
],
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader',
options: {
failOnHint: true,
typeCheck: true,
configFile: resolve('../.tslint.js'),
tsConfigFile: resolve('../tsconfig.json')
},
exclude: /node_modules/
},
{
test: /\.js$/,
loaders: ['babel-loader', 'eslint-loader'],
test: /\.[jt]s$/,
loaders: ['babel-loader', 'ts-loader'],
exclude: /node_modules/
},
{
Expand Down
8 changes: 7 additions & 1 deletion package.json
Expand Up @@ -24,13 +24,14 @@
"test:unix": "cross-env NODE_ENV=test jest",
"test:win32": "cross-env NODE_ENV=test jest -i",
"test:coverage": "cross-env NODE_ENV=test jest --coverage",
"lint": "eslint --ext .js,.vue src",
"lint": "tslint -p . -c .tslint.js src/**/*.{ts,js}",
"preparecommitmsg": "node dev/prepare-commit-message.js",
"commitmsg": "node dev/lint-commit-message.js",
"precommit": "node dev/warn-npm-install.js && yarn lint && yarn test"
},
"description": "Vue.js 2 Semantic Component Framework",
"devDependencies": {
"@types/node": "^8.0.47",
"autoprefixer": "7.2.5",
"avoriaz": "6.3.0",
"babel-cli": "6.26.0",
Expand Down Expand Up @@ -88,6 +89,11 @@
"style-loader": "0.19.1",
"stylus": "0.54.5",
"stylus-loader": "^3.0.2",
"ts-loader": "^3.0.5",
"tslint": "^5.8.0",
"tslint-config-standard": "^6.0.1",
"tslint-loader": "^3.5.3",
"typescript": "^2.5.3",
"uglifyjs-webpack-plugin": "1.1.6",
"vue": "^2.5.14",
"vue-loader": "^14.2.1",
Expand Down
13 changes: 13 additions & 0 deletions src/globals.d.ts
@@ -0,0 +1,13 @@
import { VueConstructor } from 'vue'

declare global {
interface Window {
Vue: VueConstructor
}
}

declare module 'vue/types/vue' {
interface VueConstructor {
version: string
}
}
11 changes: 8 additions & 3 deletions src/index.js → src/index.ts
@@ -1,11 +1,16 @@
import './stylus/app.styl'
import * as components from './components'
import * as directives from './directives'
import { PluginObject, VueConstructor } from 'vue'

function Vuetify (Vue, args) {
const Vuetify = components.Vuetify
declare module Vuetify {
let version: string
}

function Vuetify (Vue: VueConstructor, args: any): void {
const VuetifyComponent: PluginObject<any> = components.Vuetify

Vue.use(Vuetify, {
Vue.use(VuetifyComponent, {
components,
directives,
...args
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.dev.json
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": [
"src",
"dev"
]
}
20 changes: 20 additions & 0 deletions tsconfig.json
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"target": "es5",
"module": "es6",
"moduleResolution": "node",
"outDir": "./dist",
"sourceMap": true,
"lib": ["es2018", "dom"]
},
"include": [
"src"
],
"exclude": [
"**/*.spec.ts",
"**/*.spec.js",
"node_modules"
]
}

0 comments on commit d9e7aa6

Please sign in to comment.