Skip to content

Commit

Permalink
lintBuilt, with dts linting
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jun 18, 2020
1 parent 7bb5caf commit f424ba1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
70 changes: 51 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ const exec3 = require('./scripts/lib/shell').sync.withOptions({
exitOnError: false
})


exports.eslint = function() {
let anyFailures = false

Expand Down Expand Up @@ -366,27 +367,26 @@ exports.eslint = function() {
return Promise.resolve()
}

exports.stylelint = function() { // on BUILT css

exports.lintBuiltCss = function() {
let anyFailures = false

for (let struct of allStructs) {
if (struct.name !== '@fullcalendar/core-vdom') {
let builtCssFile = path.join(struct.dir, 'main.css')

if (fs.existsSync(builtCssFile)) {
let cmd = [
'stylelint', '--config', 'stylelint.config.js',
builtCssFile
]

console.log('Running stylelint on', struct.name, '...')
console.log(cmd.join(' '))
console.log()

let { success } = exec3(cmd)
if (!success) {
anyFailures = true
}
for (let struct of publicPackageStructs) {
let builtCssFile = path.join(struct.dir, 'main.css')

if (fs.existsSync(builtCssFile)) {
let cmd = [
'stylelint', '--config', 'stylelint.config.js',
builtCssFile
]

console.log('Running stylelint on', struct.name, '...')
console.log(cmd.join(' '))
console.log()

let { success } = exec3(cmd)
if (!success) {
anyFailures = true
}
}
}
Expand All @@ -399,6 +399,37 @@ exports.stylelint = function() { // on BUILT css
}


exports.lintBuiltDts = function() {
let anyFailures = false

for (let struct of publicPackageStructs) {
let dtsFile = path.join(struct.dir, 'main.d.ts')
console.log(`Checking ${dtsFile}`)

// look for bad module declarations (when relative, assumed NOT to be ambient, so BAD)
// look for references to react/preact (should always use vdom instead)
let { stdout } = require('./scripts/lib/shell').sync([
'grep', '-iEe', '(declare module [\'"]\\.|p?react)', dtsFile
])

stdout = stdout.trim()

if (stdout) { // don't worry about failure. grep gives failure if no results
console.log(' BAD: ' + stdout)
anyFailures = true
}

console.log()
}

if (anyFailures) {
return Promise.reject(new Error('At least one dts linting job failed'))
}

return Promise.resolve()
}


const REQUIRED_TSLIB_SEMVER = '2'

exports.lintPackageMeta = function() {
Expand Down Expand Up @@ -439,3 +470,4 @@ exports.lintPackageMeta = function() {


exports.lint = series(exports.lintPackageMeta, exports.eslint)
exports.lintBuilt = series(exports.lintBuiltCss, exports.lintBuiltDts)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"watch": "gulp watch",
"clean": "./scripts/clean.sh",
"lint": "gulp lint",
"lintBuilt": "gulp lintBuilt",
"test": "gulp test",
"test:ci": "gulp testCi",
"archive": "gulp archive",
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ FULLCALENDAR_FORCE_REACT=1 yarn run build
FULLCALENDAR_FORCE_REACT=1 yarn run test:ci

yarn run clean
yarn run lint
yarn run build
yarn run lintBuilt
yarn run archive
yarn run lint
yarn run test:ci

./scripts/packages-contrib-ci.js
Expand Down

0 comments on commit f424ba1

Please sign in to comment.