问题描述
我尝试在我的 ts 项目中添加一些 tslint 规则,但我发现它不起作用。例如:我添加了单引号规则,但是当我尝试使用双引号时,它编译成功。我的 tslint 是 6.1.3 版本,typescript 4.2.3 版本。为了您的信息,我将我的 package.json、tsconfig.json、tslint.json 和 webpack.config.js 文件粘贴在这里。 package.json:
"name": "client-side","version": "1.0.0","description": "source of ts-learning","main": "./src/index.ts","scripts": {
"test": "echo \"Error: no test specified\" && exit 1","start": "cross-env NODE_ENV=development webpack serve --mode development --env development --config ./build/webpack.config","build": "cross-env NODE_ENV=production webpack --mode production --env production --config ./build/webpack.config","lint": "tslint --project tsconfig.json"
},"keywords": [
"typescript","learning_test"
],"author": "Don","license": "MIT","devDependencies": {
"clean-webpack-plugin": "^3.0.0","html-webpack-plugin": "^5.3.0","ts-loader": "^8.0.17","tslint": "^6.1.3","typescript": "^4.2.3","webpack": "^5.24.4","webpack-cli": "^4.5.0","webpack-dev-server": "^3.11.2"
},"dependencies": {
"cross-env": "^7.0.3"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",/* Specify ECMAScript target version: 'ES3' (default),'ES5','ES2015','ES2016','ES2017','ES2018','ES2019','ES2020',or 'ESNEXT'. */
"module": "commonjs",/* Specify module code generation: 'none','commonjs','amd','system','umd','es2015','ES2020',or 'ESNext'. */
"esModuleInterop": true,/* Enables emit interoperability between Commonjs and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"skipLibCheck": true,/* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* disallow inconsistently-cased references to the same file. */
}
}
tslint.json
{
"defaultSeverity": "error","extends": [
"tslint:recommended"
],"jsRules": {},"rules": {
"quotemark": [
true,"single"
]
},"rulesDirectory": []
}
webpack.config.json
const HtmlWebpackPlugin = require('html-webpack-plugin')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const path = require('path')
module.exports = {
entry: './src/index.ts',output: {
filename: "main.js",path: path.resolve(__dirname,'dist'),},resolve: {
extensions:['.ts','.tsx','.js']
},module: {
rules: [
{ test: /\.tsx?$/,use: 'ts-loader',exclude: /node_modules/ }
]
},devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map',devServer: {
contentBase: './dist',stats: 'errors-only',compress: false,host: 'localhost',port: 8089
},plugins: process.env.NODE_ENV === 'production' ? [
new CleanWebpackPlugin(),new HtmlWebpackPlugin({
template: './src/template/index.html'
})] : [
new HtmlWebpackPlugin({
template: './src/template/index.html'
})
]
}
抱歉发布了这么多代码,其中一些可能没用。但我真的希望有人能教我解决这个问题。谢谢你。最好的祝福。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)