Next.js Discord

Discord Forum

next lint with lint-staged

Unanswered
Raspberry Horntail posted this in #help-forum
Open in Discord
Raspberry HorntailOP
currently trying use husky with lint-staged |
package.json
"scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "stylelint": "stylelint src/**/*.scss",
        "nextlint": "next lint",
        "stylelint:fix": "npm run stylelint --fix",
        "nextlint:fix": "next lint --fix",
        "lint": "next lint && npm run stylelint",
        "lint:fix": "npm run eslint:fix &&  npm run stylelint:fix"
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "src/**/*.{js,jsx,ts,tsx}": [
            "next lint --fix"
        ],
        "src/**/*.{css,scss,sass}": [
            "stylelint --fix"
        ]
    },

D:\startnext\node_modules\next\dist\lib\find-pages-dir.js:42
throw new Error("> Couldn't find any pages or app directory. Please create one under the project root");

2 Replies

Sun bear
I think "lint-staged" expects a src directory and you are not using it?

It expects:

/src/app

and you have

/app

But just my guess
@Sun bear I think "lint-staged" expects a src directory and you are not using it? It expects: /src/app and you have /app But just my guess
Raspberry HorntailOP
no i have src folder, seems like next lint looking in .next folder.