Comments (8)
@satwikkansal , either approach can work. either
- use a proper parser . See which existing parsers already parse these files. If there are bugs, raise them upstream.
- use regex to convert the
.js
into a correct JSON, and then usejson
module to load it.
re mapping tasks to bears, again both of your suggested approaches sound like they could work well.
Be bold. Try everything. Dont worry about performance. If it works, 👍 , and someone can rewrite it later if a better implementation comes along.
from coala-quickstart.
@jayvdb Just wanted to check if I understood it correctly. We've to do the following things
-
Look for a
Gruntfile.js
in the project's root and parse it if it exists. -
Find the lint subtasks using regular expressions of the form grunt.registerTask( 'lint', [ 'jshint', 'jscs:main', 'csslint' ] ) or similar.
-
Try to map the discovered sub-task to a coala-bear, if failed, warn the users.
-
If there's a mapping to some coala bear, find that specific sub-task in the config Object's top level keys and get the paths corresponding to the
all
andmain
sub-keys. -
Now, prompt the user to exclude the files found by
quickstart
not matching the paths extracted from theGruntfile.js
. These paths should be included inignore
field of the sections in generated.coafile
corresponding to the mapped bear.
I discovered that in addition to all
and main
, at some places files
sub-key is used. Example,
jshint: {
// define the files to lint
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true
}
}
}
Also I came across another kind of usage that involves src
, sources
sub-keys and default
task.
module.exports = function(grunt) {
grunt.initConfig({});
grunt.loadNpmTasks('jshint');
grunt.config('jshint', {
sources: 'sources/**.js',
tests: 'tests/**.js'
});
grunt.loadNpmTasks('less');
grunt.config('less', {
styles: {
src: 'styles/index.less',
dest: 'build/styles.css'
}
});
grunt.registerTask('default', ['jshint', 'less']);
};
IMO we should look for the above patterns as well and also take care of the sub-keys like ignore
and exclude
in config object of Gruntfile.js
.
from coala-quickstart.
That sounds very sensible. Re "Try to map the discovered sub-task to a coala-bear, if failed, warn the users." , IMO a "warning" isnt really required, and the focus should be to inform the users what parts of the Gruntfile.js were detected and enabled, and maybe a small note that -quickstart didnt recognise other parts of the Gruntfile.js , without too much detail or alarm.
from coala-quickstart.
@jayvdb Sorry to ping you again. I just had some doubts regarding:
- Parsing the
Gruntfile.js
: I'm confused whether to use a regex to extract the concerned parts or to use a parser package like slimit and pyjsparser. IMO the later approach should be more reliable. - Filtering the bears according to the
sub-tasks
: I thought of defining a dictionary oflinter
(key) andlist of bears
that use those linters inconstants.py
.
Another approach I thought of is to find the bears by matching the linte with theREQUIREMENTS
set in the class declaration of the bear (checking if it's an instance ofNPMRequirement
and then matching the name).
from coala-quickstart.
@satwikkansal , can you check whether the libraries you are using have:
- CI for Windows
- 'good' coverage (not necessarily 100%)
If not, it would be a good idea to try to do those things upstream, which hopefully doesnt result in any surprises, but ... if there are surprises you'll want to know about them now, not in phase 3 ;-)
#22 will need to be merged before your larger features are merged, otherwise the quality of your solution is unknown, and the bug reports will pour in during Google Code-In from Windows users if there are problems, catching us unprepared.
from coala-quickstart.
For JS related files I've been using pyjsparser
but it doesn't have either of
- CI for Windows
- 100% coverage (for their
tests.py
, the coverage is 30%)
I'll create upstream issues regarding both of them.
from coala-quickstart.
#22 will need to be merged before your larger features are merged, otherwise the quality of your solution is unknown.
Alright, I had appveyor in later phases, but will now adapt my timeline accordingly :)
from coala-quickstart.
Completed with a more organized approach as a part of my GSoC project (relevant commits shown above), closing it now :)
from coala-quickstart.
Related Issues (20)
- Node initialiser includes dead code HOT 1
- initialize_project_data includes dead code HOT 1
- function green_mode unnecessary delayed import of check_filename_prefix_postfix HOT 10
- UtilitiesTest.py test method test_search_for_orig contains dead code HOT 2
- test_bear_test_fun_2 contains unused test_unified_results HOT 2
- TestUtilities.py bear_test_module unused variable mocked HOT 1
- .travis.yml: Cache ntlk data
- add .coafile.green to .gitignore HOT 1
- facilitate deletion of coafile.green on running pytest HOT 3
- Investigate: how to use the nextgen-core for more reliable and easier processing of bears HOT 1
- coala-ci failing because of old version of a bear
- green_modeTest.py: Unused import AllKindsOfSettingsDependentBear HOT 3
- Unable to install for Python 3.7 HOT 2
- Use coala & coala-bears master HOT 2
- Spelling mistake taraget HOT 5
- Spelling mistake caputred HOT 1
- Add .editorconfig to moban sync HOT 1
- green_mode.py: Incomplete branch coverage on python3.6 HOT 2
- Make coala-quickstart generate configuration files in TOML
- spelling of command is incorrect in Installation section. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coala-quickstart.