Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): fixing lint error issue added flag
--type-check
- Loading branch information
1 parent
a3d2e44
commit bab9a56
Showing
5 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ng } from '../../utils/process'; | ||
import { expectToFail } from '../../utils/utils'; | ||
import { writeFile } from '../../utils/fs'; | ||
|
||
export default function () { | ||
const fileName = 'src/app/foo.ts'; | ||
const fileContents = ` | ||
const ANIMATION_CSS_VALUE_REGEX = 'asda'; | ||
const a = ["asda", 'asda', 'asdasd', "ASDASDAS"]; | ||
const b = "asdasd"; | ||
const c = { | ||
a: "sadas", | ||
b: { | ||
v: "asdasda", | ||
s: ["asda", "asdas", 10, true, "asda"], | ||
} | ||
}; | ||
function check(val: any, fxState: any) { | ||
if (typeof val === "string" && val.indexOf(" ") < 0) { | ||
let r = val.match(ANIMATION_CSS_VALUE_REGEX); | ||
let num = parseFloat(r[1]); | ||
if (!isNaN(num)) { | ||
fxState.num = num + ""; | ||
} | ||
fxState.unit = (r[0] !== r[2] ? r[2] : ""); | ||
} else if (typeof val === "number") { | ||
fxState.num = val + ""; | ||
} | ||
} | ||
`; | ||
|
||
return Promise.resolve() | ||
.then(() => writeFile(fileName, fileContents)) | ||
.then(() => expectToFail(() => ng('lint', '--fix', '--type-check'))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ng } from '../../utils/process'; | ||
import { writeFile } from '../../utils/fs'; | ||
|
||
export default function () { | ||
const fileName = 'src/app/foo.ts'; | ||
const fileContents = ` | ||
const ANIMATION_CSS_VALUE_REGEX = 'asda'; | ||
const a = ["asda", 'asda', 'asdasd', "ASDASDAS"]; | ||
const b = "asdasd"; | ||
const c = { | ||
a: "sadas", | ||
b: { | ||
v: "asdasda", | ||
s: ["asda", "asdas", 10, true, "asda"], | ||
} | ||
}; | ||
function check(val: any, fxState: any) { | ||
if (typeof val === "string" && val.indexOf(" ") < 0) { | ||
let r = val.match(ANIMATION_CSS_VALUE_REGEX); | ||
let num = parseFloat(r[1]); | ||
if (!isNaN(num)) { | ||
fxState.num = num + ""; | ||
} | ||
fxState.unit = (r[0] !== r[2] ? r[2] : ""); | ||
} else if (typeof val === "number") { | ||
fxState.num = val + ""; | ||
} | ||
} | ||
`; | ||
|
||
return Promise.resolve() | ||
.then(() => writeFile(fileName, fileContents)) | ||
.then(() => ng('lint', '--fix')) | ||
.then(() => ng('lint')) | ||
.then(({ stdout }) => { | ||
if (!stdout.match(/All files pass linting./)) { | ||
throw new Error('All files pass linting.'); | ||
} | ||
}); | ||
} |