Tslint exclude doesn't work correctly, React-Dropzone - json

I have the following structure:
components
my_component
tslint.json
tslint.json
root tslint.json
{
"extends": ["...some/tslint.json"],
"linterOptions": {
"exclude": [
"components/**/node_modules/**/",
"components/**/node_modules/*",
"components/*/node_modules/",
"node_modules"
]
}
}
component tslint.json
{
"extends": ["../../tslint.json"],
"linterOptions": {
"exclude": [
"node_modules/**"
]
}
}
But when I run "lint": "tslint \"components/**/**.ts*\""
from the root, I get these errors:
ERROR: components/my_component/node_modules/react-dropzone/typings/tests/accept.tsx[78, 22]: ' should be "
ERROR: components/my_component/node_modules/react-dropzone/typings/tests/accept.tsx[78, 36]: ' should be "
...
It should've work even without local tslint.json
But I tried to override, and even this didn't help
How to make it work?

Related

How could I use the same tslint.json in submodules, too?

A big Angular 5 project is given with several submodules (from different repositories) and I couldn't specify the path to neither node_modules/codelyzer nor tslint-base.json from a submodule's tslint.json.
The tree is something like this:
tslint-base.json
node_modules
...
modules
submod1
tslint.json
components
...
submod2
tslint.json
components
...
tslint-base.json:
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
...
}
}
Of course it works well when we open the root of the project with IDE (IntelliJ IDEA Ultimate), but we often open it from one of the submodules, not the project root. So IDE does not see the node_modules/codelyzer folder from submodule's tslint.json. I have already tried:
1. tslint.json
{
"rulesDirectory": [
"../../node_modules/codelyzer"
]
}
2. tslint.json
{
"rulesDirectory": [
"./../../node_modules/codelyzer"
]
}
3. tslint.json
{
"extends": [
"./../../tslint-base.json"
]
}
4. tslint.json
{
"extends": [
"../../tslint-base.json"
]
}
And I also tried these in combinations. But it doesn't work...
What do I wrong?

mocha and es6: Unexpected reserved word

When I tried to run unit tests using mocha, I got the following error:
> plan#1.0.0 test /root/project/plan
> NODE_PATH=app/scripts:test mocha
/root/project/plan/test/specHelper.js:3
import chai from 'chai';
^^^^^^
SyntaxError:
Unexpected reserved word
------------------------
Apparently mocha fails to apply babel to the new es6 syntax.
Here is the content of the specHelper file:
import chai from 'chai';
import sinonChai from 'sinon-chai';
import chaiEnzyme from 'chai-enzyme';
chai.use(sinonChai);
chai.use(chaiEnzyme());
chai.config.includeStack = true;
GLOBAL.expect = chai.expect;
GLOBAL.AssertionError = chai.AssertionError;
GLOBAL.Assertion = chai.Assertion;
GLOBAL.assert = chai.assert;
Here is the content of mocha.opts
--reporter min
--ui bdd
--compilers js:babel-register,less:test/ignoreCompiler,css:test/ignoreCompiler
--recursive
When I run webpack to build source code, I do not encounter any issue.
NODE_ENV=production webpack -p --config webpack.config.js
Module part in the Webpack.config.js
config.devtool = 'cheap-module-eval-source-map';
config.entry.push('webpack-dev-server/client?http://127.0.0.1:8892');
config.entry.push('webpack/hot/only-dev-server');
config.entry.push('react-hot-loader/patch');
config.output.publicPath = 'http://127.0.0.1:8892/';
config.module.rules.push({
test: /\.js$/,
use: ['babel-loader'],
exclude: /node_modules/,
include: [path.join(__dirname, 'app'), path.join(__dirname, 'test')],
});
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.plugins.push(new webpack.NoErrorsPlugin());
Content in .babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["last 2 versions", "ie >= 10"]
}
}],
"react",
"stage-0"
],
"env": {
"es": {
"presets": [["env", { "loose": true, "modules": false }], "react", "stage-0"]
},
"test": {
"presets": [
["env", {
"targets": {
"node": "7.10.1"
}
}],
"react",
"stage-0"
]
}
}
}
What did I missed in term of configuration and caused this SyntaxError?

ava: SyntaxError: Unexpected token import

So ava comes with build-in ES2015 support, which works fine for my actual test files. However, when I do
import {newUser, createUser, login} from './helpers/user';
I can't use import and export in the helper file, I then get:
Users/rowe/Code/fv/foxvision-api/test/api/helpers/user.js:1
(function (exports, require, module, __filename, __dirname) { import request from 'supertest';
SyntaxError: Unexpected token import
I have no specific babel configuration set up as for the test files it works out of the box. Can anyone explain to me why the helper dependencies are not transpiled with babel? Using test/**/helpers is even following ava convention.
Thanks,
Robin
Solution
So based on thangngoc89's solution, what I did to make it work was:
Add a .babelrc with content:
{
"presets": [
"es2015",
"stage-2"
],
"plugins": [
"espower",
"transform-runtime"
]
}
Added to package.json:
"ava": {
"require": ["babel-register"],
"babel": "inherit"
}
AVA only transpile the test files. Not test dependencies so you will need to setup babel in your project (I suppose you did it because you're using ES6 anyway).
Then in AVA's setting, add this :
"ava": {
...
"babel": "inherit"
}
It means that use your project babel setting to transpile the test dependencies. See more information in AVA docs: https://github.com/sindresorhus/ava/blob/master/docs/recipes/babelrc.md
Using rweng, my solution came out a bit simpler.
.babelrc
{
"presets": [
"es2015"
],
"plugins": [
"transform-runtime"
]
}
package.json:
"ava": {
"require": ["babel-register"],
"babel": "inherit"
}
Unfortunately standard solution didn't work for my case.
Here is my solution which worked for ava + quasar + vue project
.babelrc
{
"presets": [
"es2017",
"#ava/stage-4",
"stage-3"
],
"plugins": [
"transform-runtime"
]
}
package.json
"ava": {
"require": [
"babel-register"
],
"babel": "inherit"
},
"scripts": {
"ava": "NODE_ENV=test ava",
"test": "ava",
"test:watch": "ava --watch --verbose"
}
install modules
yarn add babel-register babel-preset-es2017 #ava/babel-preset-stage-4 babel-plugin-transform-runtime babel-preset-stage-3 --dev

Composer package not showing up in autoload_namespaces

This should be an easy one. I developed a package call it MyVendor\MyPackage
inside MyVendor\MyPackage is:
MyVendor\MyPackage\composer.json
MyVendor\MyPackage\MyClass.php
The MyVendor\MyPackage\composer.json file contains:
{
"name":"MyVendor/MyPackage",
"description":"MyClass!!!",
"keywords": ["MyKeyword"],
"homepage": "http://MyPackage.com",
"type":"library",
"license": "MIT",
"authors": [
{
"name": "ME",
"email": "ME#ME.com",
"homepage":"http://ME.com"
}
],
"require": {
},
"autoload":{
"psr-4" : {
"MyVendor\\MyPackage\\":""
}
}
}
Now I have another project called MyOtherPackage whose composer.json file looks like:
{
"require": {
"monolog/monolog": "1.2.*",
"MyVendor/MyPackage": "1.0.0"
},
"autoload": {
"psr-4": {
"MyVendor\\MyOtherPackage\\": "MyOtherPackage/",
"MyVendor\\": "/"
}
},
"repositories": [
{
"type": "package",
"package": {
"name": "MyVendor/MyPackage",
"version": "1.0.0",
"source": {
"url": "https://ME.com/svn/MyVendor/MyPackage/",
"type": "svn",
"reference": "trunk"
}
}
}
]
}
So MyOtherPackage depends on MyPackage. Everything downloads just fine, but if I open up autload_namespaces.php it only includes monolog. It looks like this:
return array(
'Monolog' => array($vendorDir . '/monolog/monolog/src'),
);
Why isn't MyVendor/MyPackage appear in the namespaces.php or autoload_psr4.php file? Is the composer.json file wrong?
EDIT I added to the MyPackage composer.json file.
I've figured it out. It seems as if defining the repository as a package, I am telling composer that it isn't a composer compatible class, which means composer doesn't look for a composer.json file.
To fix it I removed the package definition and made the dependent class's composer.json file to look like:
{
"require": {
"monolog/monolog": "1.2.*",
"MyVendor/MyPackage": "1.0.0"
},
"autoload": {
"psr-4": {
"MyVendor\\MyOtherPackage\\": "MyOtherPackage/",
"MyVendor\\": "/"
}
},
"repositories": [
{
"type": "svn",
"url": "https://ME.com/svn/MyVendor/MyPackage/",
"reference": "tags"
}
]
}
This tells composer to download the package from this repository and look for the composer.json file.
You did not define any autoload mechanism in your first package. If you don't, Composer cannot know how to autoload the classes, and does nothing (which is a valid option if your package does not contain any PHP at all, but for example only images and javascript).
Add something like this:
"autoload": {
"psr-0": {
"MyVendor\\Namespace":"src/path"
}
}

folder path in sublime text build system

My sublime project looks like this:
{
"folders":
[
{
"folder_exclude_patterns":
[
".bzr",
"build",
"webapps",
"work",
".settings"
],
"path": "/home/charles/project/Editor/trunk"
}
],
"settings":
{
"build_on_save": true,
"filename_filter": "\\.(java)$",
"tab_size": 4,
"translate_tabs_to_spaces": false
},
"build_systems":
[
{
"name": "compile",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
}
When I save a file the console says:
Buildfile: dev.xml does not exist!
Build failed
[Finished in 0.2s with exit code 1]
I know that I need to put something before dev.xml but I don't know what.
I found some possibilities here: http://sublimetext.info/docs/en/reference/build_systems.html#variables
But What I need is the folder path "/home/charles/project/Editor/trunk" in my case...
Any idea how I can achieve this?
You are missing "working_dir" in your "build_systems" setup. The example below will use the directory that holds the sublime project file as the build starting directory.
"build_systems":
[
{
"name": "compile",
"working_dir": "${project_path}",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
More information can be found at: http://www.sublimetext.com/docs/2/projects.html