This project was written by someone else, and I need to work on it from hereon. I thought that the first step should be to fix the formatting. Normally, I just use .prettierrc in my vscode, and a run a alt-shift-f, or ctrl-s to format the code in each file. I tried to use eslint, but got all kinds of errors, so I got rid of it (uninstalled all the eslint dev-dependencies in the project, as was the case before I started working on it). I have the prettier and the eslint extensions installed in vscode.
Error
["ERROR" - 1:45:44 pm] Error formatting document.
["ERROR" - 1:45:44 pm] `import` can only be used in `import()` or `import.meta`. (1:1)
> 1 | import { subMonths, isSameDay, format, isYesterday, isToday, subDays, subYears } from 'date-fns';
| ^
2 |
3 | export const today = new Date();
4 | export const last7Day = {
SyntaxError: `import` can only be used in `import()` or `import.meta`. (1:1)
root > .vscode > settings.json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
// other configs
}
root > frontend > .prettierrc
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"parser": "json"
}
How do I get my prettier file to ignore this error? It's coming on all the files. OS: Windows 10
UPDATE: This is the following in my package.json. I don't normally install prettier, but I'm at a bit of a loss at what to do. From my understanding, this was more of a IDE-thing, rather than a project thing.
"eslintConfig": {
"extends": ["react-app", "react-app/jest"]
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "^2.5.1"
}