Code Monkey home page Code Monkey logo

Comments (5)

kentcdodds avatar kentcdodds commented on May 17, 2024

Thanks for the idea! Sounds like that'd be useful! Feel free to make a pull request 😀

from prettier-eslint-cli.

calebeby avatar calebeby commented on May 17, 2024

I figured you'd ask 😄
I looked at the code a bit, can you point me to which function I should add the logic to?

from prettier-eslint-cli.

kentcdodds avatar kentcdodds commented on May 17, 2024

Relevant code here:

function isFilePathMatchedByEslintignore(filePath) {
const eslintignorePath = getNearestEslintignorePath(filePath)
if (!eslintignorePath) {
return false
}
const eslintignoreDir = path.parse(eslintignorePath).dir
const filePathRelativeToEslintignoreDir = path.relative(
eslintignoreDir,
filePath,
)
const isIgnored = getIsIgnoredMemoized(eslintignorePath)
return isIgnored(filePathRelativeToEslintignoreDir)
}

Similar tests are here:

test('wont modify a file if it is eslint ignored', async () => {
await formatFiles({_: ['src/**/ignored*.js'], write: true})
expect(fsMock.readFile).toHaveBeenCalledTimes(1)
expect(fsMock.writeFile).toHaveBeenCalledTimes(1)
expect(fsMock.readFile).toHaveBeenCalledWith(
expect.stringMatching(/applied/),
'utf8',
expect.any(Function),
)
expect(fsMock.writeFile).toHaveBeenCalledWith(
expect.stringMatching(/applied/),
expect.stringMatching(/MOCK_OUTPUT.*?applied/),
expect.any(Function),
)
const ignoredOutput = expect.stringMatching(/success.*1.*file/)
expect(console.error).toHaveBeenCalledWith(ignoredOutput)
})
test('will modify a file if it is eslint ignored with noIgnore', async () => {
await formatFiles({
_: ['src/**/ignored*.js'],
write: true,
eslintIgnore: false,
})
expect(fsMock.readFile).toHaveBeenCalledTimes(4)
expect(fsMock.writeFile).toHaveBeenCalledTimes(4)
const ignoredOutput = expect.stringMatching(/success.*4.*files/)
expect(console.error).toHaveBeenCalledWith(ignoredOutput)
})
test('will not blow up if an .eslintignore cannot be found', async () => {
const originalSync = findUpMock.sync
findUpMock.sync = () => null
try {
await formatFiles({
_: ['src/**/no-eslint-ignore/*.js'],
write: true,
})
} catch (error) {
throw error
} finally {
findUpMock.sync = originalSync
}
})

Good luck! And thanks :)

from prettier-eslint-cli.

calebeby avatar calebeby commented on May 17, 2024

I realized you were right about not needing this project, so I'm not going to create a PR for this. Feel free to close this if you want, or just let it open.

from prettier-eslint-cli.

github-actions avatar github-actions commented on May 17, 2024

Stale issue

from prettier-eslint-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.