Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
session-g1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
session-g1
Commits
ff656de8
Commit
ff656de8
authored
1 year ago
by
William Grant
Browse files
Options
Downloads
Patches
Plain Diff
fix: lint-staged ignores files using eslintignore
parent
5fcad9ce
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.lintstagedrc.js
+33
-20
33 additions, 20 deletions
.lintstagedrc.js
with
33 additions
and
20 deletions
.lintstagedrc.js
+
33
−
20
View file @
ff656de8
const
ignoredFiles
=
[
const
{
ESLint
}
=
require
(
'
eslint
'
);
'
package.json
'
,
'
yarn.lock
'
,
const
removeIgnoredFiles
=
async
files
=>
{
'
tsconfig.json
'
,
const
eslint
=
new
ESLint
();
'
.lintstagedrc.js
'
,
const
isIgnored
=
await
Promise
.
all
(
'
.eslintrc.js
'
,
files
.
map
(
file
=>
{
];
return
eslint
.
isPathIgnored
(
file
);
})
const
path
=
require
(
'
path
'
);
);
const
filteredFiles
=
files
.
filter
((
_
,
i
)
=>
!
isIgnored
[
i
]);
const
buildFormatCommand
=
filenames
=>
{
return
filteredFiles
.
join
(
'
'
);
const
results
=
filenames
};
.
map
(
f
=>
path
.
relative
(
process
.
cwd
(),
f
))
.
filter
(
f
=>
!
ignoredFiles
.
includes
(
f
));
const
buildFormatCommand
=
async
files
=>
{
const
filesToLint
=
await
removeIgnoredFiles
(
files
);
return
results
.
length
?
`prettier --list-different --write
${
results
.
join
(
'
'
)}
`
:
''
;
if
(
!
filesToLint
||
!
filesToLint
.
length
)
{
return
''
;
}
const
results
=
filesToLint
.
map
(
f
=>
path
.
relative
(
process
.
cwd
(),
f
));
return
results
.
length
?
`prettier --ignore-unknown --list-different --write
${
results
.
join
(
'
'
)}
`
:
''
;
};
};
const
buildLintCommand
=
filenames
=>
{
const
buildLintCommand
=
async
files
=>
{
const
results
=
filenames
const
filesToLint
=
await
removeIgnoredFiles
(
files
);
.
map
(
f
=>
path
.
relative
(
process
.
cwd
(),
f
))
.
filter
(
f
=>
!
ignoredFiles
.
includes
(
f
));
if
(
!
filesToLint
||
!
filesToLint
.
length
)
{
return
''
;
}
const
results
=
filesToLint
.
map
(
f
=>
path
.
relative
(
process
.
cwd
(),
f
));
return
results
.
length
?
`eslint --cache
${
results
.
join
(
'
'
)}
`
:
''
;
return
results
.
length
?
`eslint --cache
${
results
.
join
(
'
'
)}
`
:
''
;
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment