-
-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update: Rename babylon parser to babel #205
Conversation
Our minimum supported version of prettier is In order to not break people using 1.13.0 to 1.15.last, This will require either:
Can you take a stab at the later. |
@BPScott thank you very much for your feedback! |
Just for information purposes, by setting the parser to babel in .eslintrc.js rules the warning disappears.
module.exports = {
env: { browser: true, es6: true },
extends: ["eslint:recommended", "plugin:prettier/recommended"],
parserOptions: { ecmaVersion: 2018 },
plugins: ["prettier", "html"],
rules: {
"prettier/prettier": ["error", { semi: false, printWidth: 100, parser: "babel" }],
"comma-dangle": ["error", "never"]
}
} |
@robertoentringer for the most part you shouldn't ever need to set an explicit parser as it should be inferred by the filename, or indeed any other options (as they should be read from your .prettierrc per this note. What's the filename of the file that you're parsing that causes this to appear? A better fix would probably be to use the overrides section of your prettierrc file to specify the parser for the file extension you desire. This comment offers instructions on how you can set those the parser using overrides. (that comment is relating to stylelint-prettier but the concept of configuring prettier overrides in prettier's config files instead of eslint/stylelint's config is the same. |
@BPScott the filename is index.html and I use the eslint-plugin-prettier. Setting the parser for html's files inside the .prettierrc file works very well: {
"overrides": [
{
"files": "*.html",
"options": { "parser": "babel" }
}
]
} However, I like to use a single file for config prettier+eslint. But, if I use the same config inside the .eslintrc.js it has no any effect! Is there any way to implement this? I did not find anything about it at options. module.exports = {
env: { browser: true, es6: true },
extends: ["eslint:recommended", "plugin:prettier/recommended"],
parserOptions: { ecmaVersion: 2018 },
plugins: ["prettier", "html"],
rules: {
"prettier/prettier": [
"error",
{
semi: false,
printWidth: 100,
overrides: [
{
files: "*.html",
options: { parser: "babel" }
}
]
}
],
"comma-dangle": ["error", "never"]
}
} This is my package.json : {
"scripts": {
"lint": "eslint --fix src/**/*.{js,html}"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-html": "^5.0.5",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2"
}
} Thank you for the good advice about this note and this comment. |
Setting overrides would work in every case but this - as per the comment above the line in your PR we force the parser value for html files because we want to try and automatically do the right thing in 90% of the cases rather than forcing people to add this sort of config. It sounds like the fix is for us to update the parser name that we force based upon |
That looks great! thanks for investigating the structure of that. To save you some work I've added this in #212 |
Prevent message : { parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
Related : prettier/prettier#5647