Skip to content

Commit 7030fa7

Browse files
committed
fix(lint): 修复context改变时lint路径问题
1 parent cdc1ad3 commit 7030fa7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/config/eslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"commonjs": true,
55
"node": false
66
},
7-
"extends": "eslint:recommended",
7+
"extends": ["eslint:recommended"],
88
"globals": [
99
"$", "$$", "jQuery", "Promise"
1010
],

src/models/Project.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ class Project {
144144
lint(callback) {
145145
warn('Lint JS Files ......');
146146
this.eslintConfig.useEslintrc = false;
147-
let cli = new CLIEngine(this.eslintConfig),
147+
148+
const jsPath = sysPath.join(this.config._config.context, '/**/*.js'),
149+
cli = new CLIEngine(this.eslintConfig),
148150
report = cli.executeOnFiles(
149-
globby.sync('src/**/*.js', {
151+
globby.sync(jsPath, {
150152
cwd: this.cwd
151153
})
152154
.filter(
@@ -159,9 +161,15 @@ class Project {
159161
}
160162
lintCss(callback) {
161163
warn('Lint CSS Files ......');
164+
165+
const cssExtNames = this.config._config.entryExtNames.css,
166+
cssLintPath = cssExtNames.map((cssExt) => {
167+
return sysPath.join(this.config._config.context, '/**/*' + cssExt)
168+
});
169+
162170
let config = {
163171
config: this.stylelintConfig,
164-
files: globby.sync(['src/**/*.css', 'src/**/*.sass', 'src/**/*.scss'], {
172+
files: globby.sync(cssLintPath, {
165173
cwd: this.cwd
166174
})
167175
.filter(
@@ -170,6 +178,7 @@ class Project {
170178
syntax: 'scss',
171179
formatter: 'verbose'
172180
};
181+
173182
if (config.files.length) {
174183
stylelint.lint(config).then(function(data) {
175184
if (data.errored) {

0 commit comments

Comments
 (0)