Prettier breaks the import statement into two lines - prettier

I am trying to prevent prettier from breaking my code. Current setup causes an import statement that is 125 characters long to break into 2 lines which results in an error.
import DiagnosticsResponseMessageContainer from 'components/DiagnosticsResponseMessage/DiagnosticsResponseMessageContainer';
The import line looks like this after save, and I get red squeaky lines under from saying that I need { to fix it:
import DiagnosticsResponseMessageContainer,
from 'components/DiagnosticsResponseMessage/DiagnosticsResponseMessageContainer';
Tried changing printWidth value to 250, 1000, and 5000 but it didn't affect the behaviour.
Checked if I'm using any other similar tools such as Beautify, but I'm not.
Added the recommended package tslint-config-prettier to make sure tslint/prettier working together not causing this issue
Tried adding // prettier-ignore before the import line. Didn't change anything
This is the output of prettier after save:
["INFO" - 11:25:39 AM] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 11:25:39 AM] Prettier Options:
{
"filepath": "***",
"parser": "typescript",
"bracketSpacing": true,
"printWidth": 250,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"quoteProps": "preserve"
}
["INFO" - 11:25:39 AM] Formatting completed in 0.091ms.
What might be the problem here?

Related

pylint django with django-configurations

UPDATE 2021 March 29 : There is a known issue here
How to make pylint-django work together with django-configurations ?
I've setup a Django project in VS code with pylint and django-pylint as linter.
I have a conflict with django-configurations, a package that I use to have different config file depending on environment.
I specify django-settings-module in order for django-pylint to understand django project.
Settings.json in vscode looks like this :
{
// ...
"python.linting.pylintArgs": [
"--load-plugins", "pylint_django", // Works fine
// "--django-settings-module", "project.settings" // Do not work anymore when adding this
],
],
// ...
}
Also I've tried the same config file with another django project that does not use django-configurations and pylint django works well with second line on.
I managed to make this work with this format:
{
"python.linting.pylintArgs": [
"--load-plugins",
"pylint_django",
"--django-settings-module=project.settings"
]
}

Issue integrating cypress-angular-unit-test into Cypress plugins

I am attempting to add the cypress-angular-unit-test plugin to Cypress.
However, following the instructions provided on the related GitHub page I am getting the following error:
The plugins file is missing or invalid.
/MyProjectName/cypress/plugins/index.js:1
import * as cypressTypeScriptPreprocessor from 'cy-ts-preprocessor';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Again, as instructed, I have added the following to support/index.js
// core-js 3.*
require('core-js/es/reflect');
// core-js 2.*
require('core-js/es7/reflect');
require('cypress-angular-unit-test/support');
And the following to plugins/index.js
import * as cypressTypeScriptPreprocessor from 'cy-ts-preprocessor';
module.exports = (on, config) => {
on('file:preprocessor', cypressTypeScriptPreprocessor);
require('#cypress/code-coverage/task')(on, config);
return config;
};
I've also added the related helper.js and cy-ts-preprocessor.js file to the plugins folder.
I've also added the necessary config to cypress.json
"experimentalComponentTesting": true,
I've even tried adding types/node by adding a tsconfig.json to the cypress folder like so:
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"],
"experimentalDecorators": true
},
"include": [
"**/*.ts"
]
}
Changing the target and/or lib values to es6 has no effect.
Changing the import to a require yields a different error which, even if it did work, seems like a hacky solution for some detail I am missing.
¯\_(ツ)_/¯
Not exactly an answer but at least a work around.
Start fresh or uninstall Cypress and cypress-angular-unit-test
Follow the instructions for Nx Cypress install found on here
Go back to cypress-angular-unit-test instructions and ignore this part:
Configure cypress/plugins/index.js to transpile Angular code.
import * as cypressTypeScriptPreprocessor from './cy-ts-preprocessor';
module.exports = (on, config) => {
on('file:preprocessor', cypressTypeScriptPreprocessor);
return config;
};
The file cy-ts-preprocessor is here

Python logger prints line twice without configure_logging()

When using the python logger, my program starts fine with logging but at some point the log output starts outputting lines twice, looking like this:
DEBUG:pluginbrowser:Scanning plugs
DEBUG:pluginbrowser:Doing good stuff
....
INFO:pluginbrowser:=== doing something ===
=== doing something ===
Currently all my python files contain the line
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
Thus, the doubled message comes from the pluginbrowser.py file. Examining this, I found out that at the beginning of my program, the same files output some log without double-ing the lines. I tried to find out at which point exactly it happens but I am somehow stuck here.
I also read log messages appearing twice with Python Logging but I am not using configure_logging at all.
Looks like you add an additional handler somewhere along the way.
I would search for addHandler in the code. You could also debug and watch logger.root.handlers
This is how I could reproduce your effects:
In [1]: import logging
In [2]: logging.basicConfig(level=logging.DEBUG)
In [3]: logger = logging.getLogger('pluginbrowser')
In [4]: logger.info('=== doing something ===')
INFO:pluginbrowser:=== doing something ===
In [5]: logging.root.addHandler(logging.StreamHandler())
In [6]: logger.info('=== doing something ===')
INFO:pluginbrowser:=== doing something ===
=== doing something ===

I am having an issue with pylint within visual studio code workspace settings

Every single one of the immport statements I make within the project files are giving an error:
[Python] unresolved import 'user.models'
with this statement:
from users.models import Detail
Here is my workspace settings.json file within my .vscode folder:
{
"python.pythonPath": "/Applications/Python3/bin/python3",
"editor.formatOnSave": true,
"python.linting.pep8Enabled": true,
"python.linting.pylintPath": "pylint",
"python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
"python.venvPath": "${workspaceFolder}/backend/env/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.pep8Args": [
"--ignore-E501"
],
"git.ignoreLimitWarning": true
}
pyling_django should be pylint_django, and you need to make sure your python path is correct, and your ENV is activated.

django-cms==3.2.3 migration from Django 1.5.12 to 1.9.5 choices error

While working a migration of an older Django project I ran into this error after running:
python manage.py check
cms.UserSettings.language: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.
Has anyone run into this issue? Unfortunately I have to wait until I am not on the corp network before I can ask the IRC channels.
http://docs.django-cms.org/en/latest/reference/configuration.html#cms-languages
It turns out I missed this important setting in my settings.py file:
CMS_LANGUAGES = {
'default': {
'fallbacks': ['en',],
'redirect_on_fallback':True,
'public': True,
'hide_untranslated': False,
}
}
Thanks to brianpck for a point in the right direction though.