Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
.opt-out
.DS_Store
.eslintcache
.idea
10 changes: 6 additions & 4 deletions src/config/lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const {resolveHoverScripts, resolveBin} = require('../utils')

const kcdScripts = resolveHoverScripts()
const hoverScripts = resolveHoverScripts()
const doctoc = resolveBin('doctoc')

module.exports = {
'README.md': [`${doctoc} --maxlevel 3 --notitle`],
'*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx|vue)': [
`${kcdScripts} format`,
`${kcdScripts} lint`,
`${kcdScripts} test --findRelatedTests`,
`${hoverScripts} format`,
],
'*.+(js|jsx|ts|tsx)': [
`${hoverScripts} lint`,
`${hoverScripts} test --findRelatedTests`,
],
}
2 changes: 0 additions & 2 deletions src/scripts/__tests__/__snapshots__/lint.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ exports[`lint does not use built-in ignore with .eslintignore file 1`] = `eslint
exports[`lint does not use built-in ignore with --ignore-path 1`] = `eslint --config ./src/config/eslintrc.js --cache --cache-location <PROJECT_ROOT>/node_modules/.cache/.eslintcache --ext .js,.jsx,.ts,.tsx --ignore-path ./my-ignore .`;

exports[`lint does not use built-in ignore with eslintIgnore pkg prop 1`] = `eslint --config ./src/config/eslintrc.js --cache --cache-location <PROJECT_ROOT>/node_modules/.cache/.eslintcache --ext .js,.jsx,.ts,.tsx .`;

exports[`lint runs on given files, but only js and ts files 1`] = `eslint --config ./src/config/eslintrc.js --ignore-path ./src/config/eslintignore --cache --cache-location <PROJECT_ROOT>/node_modules/.cache/.eslintcache --ext .js,.jsx,.ts,.tsx ./src/index.js ./src/index.ts ./src/component.jsx ./src/component.tsx`;
10 changes: 0 additions & 10 deletions src/scripts/__tests__/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,5 @@ cases(
'--no-cache will disable caching': {
args: ['--no-cache'],
},
'runs on given files, but only js and ts files': {
args: [
'./src/index.js',
'./src/index.ts',
'./package.json',
'./src/index.css',
'./src/component.jsx',
'./src/component.tsx',
],
},
},
)
9 changes: 1 addition & 8 deletions src/scripts/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const spawn = require('cross-spawn')
const yargsParser = require('yargs-parser')
const {hasPkgProp, resolveBin, hasFile, fromRoot} = require('../utils')

let args = process.argv.slice(2)
const args = process.argv.slice(2)
const here = p => path.join(__dirname, p)
const hereRelative = p => here(p).replace(process.cwd(), '.')
const parsedArgs = yargsParser(args)
Expand Down Expand Up @@ -42,13 +42,6 @@ const filesGiven = parsedArgs._.length > 0

const filesToApply = filesGiven ? [] : ['.']

if (filesGiven) {
// we need to take all the flag-less arguments (the files that should be linted)
// and filter out the ones that aren't js files. Otherwise json or css files
// may be passed through
args = args.filter(a => !parsedArgs._.includes(a) || /\.(j|t)sx?$/.test(a))
}

const result = spawn.sync(
resolveBin('eslint'),
[...config, ...ignore, ...cache, ...extensions, ...args, ...filesToApply],
Expand Down