Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
finn-js-code-style
Advanced tools
This project is meant for internal JS-code at FINN.no, but we have many public JS projects which also want to use the same code style. Feel free to use/fork, but it probably will become very FINN specific, so we don't expect it to be very useful for others.
The JSHint config is just a beginning and up for discussion. The most important is that we land on a config that everyone uses. So it's better with a relaxed config that everyone use than a strict config that nobody wants to use. But the main concept of linting code is to avoid potential typos, so it's a fine balance...
Add a pull-request if you want to change something and we can discuss on the pull-request. One pull-request pr option change. Please include the description of the option in the PR description :)
npm install --save-dev finn-js-code-style
This command will run jshint on the files you specify. In the future, it will probably do more code style checks on the same set of files.
finn-js-code-style [options] <file | dir>...
--help
Usage info--max-warnings <number>
Exit when more warnings than max-warnings
--max-errors <number>
Exit when more errors than max-errors
--fail
Exit when warnings/errors are generatedSee CHANGELOG.md for what has changed since last release
The config should be in the dot-files instead of hard-coded in build scripts. That makes it possible for editor plugins to auto-detect the config.
If you already have a .jshintrc
file; add the line below and remove all old rules. If you don't have it, finn-js-code-style will generate it the first time you run the command.
"extends": "./node_modules/finn-js-code-style/.jshintrc"
The extends
option became usable in jshint v2.5.1, so make sure the version you use (also editor plugins) at least have this version.
It is possible to extend js-code-style with a project-specific config, but we only allow a more strict set of rules or change the environment (node/browser). The project globals should also be defined here (if you have any), and will extend the parent´s globals (instead of overwriting).
You can also use extends
to have different config for tests or similar:
./.jshintrc
{
"extends": "./node_modules/finn-js-code-style/.jshintrc",
"browser": true,
"node": false,
"maxstatements": 10
}
./test/.jshintrc
{
"extends": "../.jshintrc",
"globals": {
"suite": true,
"test": true,
"setup": true,
"teardown": true,
"assert": true
}
}
Use the .jshintignore
to exclude files or folders.
npm install --save-dev grunt-exec
In Gruntfile.js
grunt.loadNpmTasks('grunt-exec');
grunt.initConfig({
//...,
exec: {
finn_js_code_style: {
cmd: 'finn-js-code-style src'
}
},
//...
});
- Install plugin...
- Open prefrences in Intellij.
- Under Project Settings find: JavaScript -> Code Quality Tools -> JSHint.
- Check off for "Enable", "Use config files" and "2.8.0".
See JSHint docs
# patch version
$ npm run release:patch
# minor version
$ npm run release:minor
# major version
$ npm run release:major
# special versions (alpha/beta/etc) 1.2.3-beta.1
$ npm version <newversion>
$ NPM_CONFIG_TAG=<tag> npm run push-package-publish
[5.0.0] - 2016-03-04
We're working on switching to ESLint, but this beta has been waiting way too long. So releasing the beta 9 with minor changes.
ESLint will be a new major release because it will have breaking changes (new set of rules).
FAQs
Config files for FINN JavaScript style
We found that finn-js-code-style demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.