Permalink
Browse files

chore(lint): Introduce shared lint configuration and initial code sty…

…le documentation.
  • Loading branch information...
chriseppstein committed Feb 11, 2018
1 parent 5b28b71 commit c361bc010dce8de0c2cd18768392a06a717491e9
@@ -0,0 +1,10 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-full-stop': [2, 'always', '.'],
'subject-case': [
2, 'always',
['sentence-case']
]
}
}
@@ -16,7 +16,7 @@
"path": "packages/webpack-plugin"
},
{
"path": "packages/webpack-plugin"
"path": "packages/code-style"
}
],
"settings": {
@@ -1,14 +1,14 @@
{
"private": true,
<<<<<<< HEAD
"scripts": {
"commitmsg": "commitlint -e $GIT_PARAMS"
},
"devDependencies": {
"@commitlint/cli": "^6.1.0",
"@commitlint/config-conventional": "^6.1.0",
"husky": "^0.14.3",
"lerna": "^2.5.1"
},
=======
"devDependencies": {
"lerna": "^2.5.1"
},
>>>>>>> 65ec8b6... Squash with 4420cd6e5efaf53b5c9ae2a2c4bfd82407cb4373
"workspaces": [
"packages/*"
]
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"transpiled"
]
}
@@ -0,0 +1,74 @@
Code Style for `css-blocks`
===========================
This project adheres to the following conventions for code and its style.
These conventions govern the code that runs during build-time. There are
separate conventions for code intended to run in the browser.
Node Support Policy
-------------------
Starting with Node 8, CSS Blocks and related projects will support all
[Active LTS releases of Node][node-releases]. Once a node version moves into
"Maintenance LTS" we reserve the right to drop support for it with the next
*minor* release. Our projects are configured to set the node `engine` version
in their `package.json`, so such releases will not regress for projects using
older versions of node &mdash; but bug fixes and new features may not be
released.
The exception to this is that critical security patches will be released for
versions of our software to support projects using Node that remains in the
Maintenance LTS mode.
Code Style
----------
1. Code is written in TypeScript and transpiled to the newest version of ES
Modules that are supported by our Node Support Policy (see above).
2. All TypeScript code will use this project's configuration
files where possible.
3. Linting must be performed as part of `yarn test` for every node package.
4. All code is compiled with TypeScript's strictest settings enabled and
any new strictness options are enabled with each TypeScript release.
5. Specific Lint rules ran are not covered here. The source of truth is
the [`tslint.json`][tsconfig-file] file.
6. Avoid `any`. There are very few times it's necessary. We use
the type `something` from `@opticss/util` to express very generic
values without introducing the infectious semantics of `any`.
Exceptions:
a. [Type guards][type-guards] can accept an argument of type `any`.
b. Callbacks whose return value is not consumed can have a declared
return value of `any`.
Test Code Style
---------------
Test code is linted like source code. Exceptions and Additions to those rules
are listed here:
1. Testing is done with [`ts-mocha`][ts-mocha], [`chai`][chai] for assertions.
2. Do not use "bdd-style" assertions (e.g. expect/should) for tests.
3. Tests that use randomization or fuzzing to test a feature must
include information in the output or error that makes it easy to reproduce
the error either by seeding the random number generator or by including
the actual values used in the error message.
4. Integration testing is preferred to unit tests so that tests are robust
against internal refactors.
5. When unit testing, there is a preference for adding internal APIs to real
objects over using mocks/stubs or other tools to inspect that a test had the
expected outcomes to its unit and to the units it interacts with.
Editor/IDE
----------
This project recommends the use of Visual Studio Code and includes
configuration for integration with it to enhance the IDE experience
with the tooling choices of the project and makes things like
interactive debugging work easily while running the tests.
[node-releases]: https://github.com/nodejs/Release
[tsconfig-file]: https://github.com/css-blocks/css-blocks/tree/master/packages/code-style/configs/tslint.json
[type-guards]: https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
[ts-mocha]: https://www.npmjs.com/package/ts-mocha
[chai]: http://chaijs.com/api/assert/
@@ -0,0 +1,28 @@
{
"rules": {
"curly": false,
"no-var-keyword": true,
"adjacent-overload-signatures": true,
"no-for-in-array":true,
"no-unsafe-any": {
"severity": "warn"
},
"indent": [true, "spaces"],
"label-position": true,
"no-consecutive-blank-lines": [
true
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-trailing-whitespace": true,
"no-unused-expression": true,
"semicolon": [true, "always"],
"triple-equals": true,
"class-name": true,
"no-default-export": {
"severity": "warn"
}
}
}
@@ -0,0 +1,14 @@
{
"name": "@css-blocks/code-style",
"version": "0.17.0",
"main": "configs/tslint.json",
"readme": "README.md",
"bugs": {
"url": "https://github.com/css-blocks/css-blocks/issues"
},
"repository": {
"url": "https://github.com/css-blocks/css-blocks.git",
"type": "git"
},
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/code-style"
}
@@ -5,9 +5,9 @@
"main": "dist/src/index.js",
"scripts": {
"compile": "rm -rf dist && tsc -p test/tsconfig.json",
"pretest": "npm run compile && tslint --project tsconfig.json --type-check",
"pretest": "npm run compile && tslint --project tsconfig.json",
"prepublish": "npm run compile",
"tslint": "tslint --project tsconfig.json",
"lint": "tslint --project tsconfig.json",
"test": "mocha dist/test --opts test/mocha.opts",
"coverage": "istanbul cover -i \"dist/src/**/*.js\" --dir ./build/coverage node_modules/.bin/_mocha -- dist/test --opts test/mocha.opts",
"remap": "remap-istanbul -i build/coverage/coverage.json -o coverage -t html",
@@ -35,6 +35,7 @@
],
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/css-blocks#readme",
"devDependencies": {
"@css-blocks/code-style": "^0.17.0",
"@opticss/util": "^0.1.1",
"@types/chai": "^3.5.2",
"@types/mocha": "^2.2.41",
@@ -1,21 +1,3 @@
{
"rules": {
"curly": false,
"no-var-keyword": true,
"indent": [true, "spaces"],
"label-position": true,
"no-consecutive-blank-lines": [
true
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-trailing-whitespace": true,
"no-unused-variable": true,
"no-unused-expression": true,
"semicolon": [true, "always"],
"triple-equals": true,
"class-name": true
}
"extends": "@css-blocks/code-style"
}
@@ -12,9 +12,9 @@
"scripts": {
"test": "mocha --opts test/mocha.opts dist/test",
"compile": "rm -rf dist && tsc -p test/tsconfig.json",
"pretest": "npm run compile && npm run tslint",
"pretest": "npm run compile && npm run lint",
"prepublish": "npm run compile",
"tslint": "tslint --project tsconfig.json --type-check",
"lint": "tslint --project tsconfig.json",
"coverage": "istanbul cover -i dist/src/**/*.js --dir ./build/coverage node_modules/mocha/bin/_mocha -- dist/test --opts test/mocha.opts",
"remap": "remap-istanbul -i build/coverage/coverage.json -o coverage -t html",
"docs": "typedoc --out ./docs .",
@@ -43,6 +43,7 @@
},
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/glimmer-templates#readme",
"devDependencies": {
"@css-blocks/code-style": "^0.17.0",
"@types/chai": "^3.5.2",
"@types/debug": "0.0.29",
"@types/mocha": "^2.2.41",
@@ -1,21 +1,3 @@
{
"rules": {
"curly": false,
"no-var-keyword": true,
"indent": [true, "spaces"],
"label-position": true,
"no-consecutive-blank-lines": [
true
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-trailing-whitespace": true,
"no-unused-variable": true,
"no-unused-expression": true,
"semicolon": [true, "always"],
"triple-equals": true,
"class-name": true
}
"extends": "@css-blocks/code-style"
}
@@ -9,6 +9,15 @@
"opticss",
"truthy"
],
"cSpell.ignorePaths": [
"**/node_modules/**",
"**/vscode-extension/**",
"**/.git/**",
".vscode",
"typings",
"package.json"
],
"tslint.packageManager": "yarn",
"npm.packageManager": "yarn"
"npm.packageManager": "yarn",
"tslint.enable": true
}
@@ -8,12 +8,12 @@
"dist"
],
"scripts": {
"pretest": "npm run build && npm run tslint",
"pretest": "npm run build && npm run lint",
"test": "mocha dist/test --recursive --opts test/mocha.opts",
"build": "rm -rf dist && tsc --jsx preserve -p tsconfig.json",
"prepublish": "npm run build",
"watch": "watch 'npm run test' './src' './test' --wait=3",
"tslint": "tslint --project tsconfig.json --type-check"
"lint": "tslint --project tsconfig.json"
},
"repository": {
"type": "git",
@@ -34,6 +34,7 @@
},
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/jsx#readme",
"devDependencies": {
"@css-blocks/code-style": "^0.17.0",
"@css-blocks/runtime": "^0.17.0",
"@types/babel-core": "^6.25.2",
"@types/babel-generator": "^6.25.0",
@@ -50,8 +50,8 @@ const CAN_PARSE_EXTENSIONS = {
'.jsx': true,
};
export default function mkTransform(tranformOpts: { rewriter: Rewriter }): () => PluginObj<CssBlocksVisitor> {
const rewriter = tranformOpts.rewriter;
export default function mkTransform(transformOpts: { rewriter: Rewriter }): () => PluginObj<CssBlocksVisitor> {
const rewriter = transformOpts.rewriter;
return function transform(): PluginObj<CssBlocksVisitor> {
@@ -1,20 +1,3 @@
{
"rules": {
"curly": false,
"no-var-keyword": true,
"indent": [ true, "spaces" ],
"label-position": true,
"no-consecutive-blank-lines": [ true ],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unused-variable": true,
"semicolon": [ true, "always" ],
"triple-equals": true,
"class-name": true,
"quotemark": [ true, "single", "jsx-double", "avoid-escape" ]
}
"extends": "@css-blocks/code-style"
}
@@ -8,11 +8,11 @@
"dist"
],
"scripts": {
"pretest": "npm run build && npm run tslint",
"pretest": "npm run build && npm run lint",
"test": "echo 'tested in @css-blocks/jsx'",
"build": "rm -rf dist && tsc",
"prepublish": "npm run build",
"tslint": "tslint --project tsconfig.json"
"lint": "tslint --project tsconfig.json"
},
"repository": {
"type": "git",
@@ -28,6 +28,7 @@
},
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/runtime/#readme",
"devDependencies": {
"@css-blocks/code-style": "^0.17.0",
"grunt": "^1.0.1",
"grunt-release": "^0.12.0",
"tslint": "^5.5.0",
@@ -1,20 +1,3 @@
{
"rules": {
"curly": false,
"no-var-keyword": true,
"indent": [ true, "spaces" ],
"label-position": true,
"no-consecutive-blank-lines": [ true ],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-inferrable-types": [true],
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unused-variable": true,
"semicolon": [ true, "always" ],
"triple-equals": true,
"class-name": true,
"quotemark": [ true, "single", "jsx-double", "avoid-escape" ]
}
"extends": "@css-blocks/code-style"
}
@@ -6,7 +6,7 @@
"scripts": {
"prepublish": "tsc -p tsconfig.json",
"pretest": "tsc -p tsconfig.json && tslint --project tsconfig.json",
"tslint": "tslint --project tsconfig.json",
"lint": "tslint --project tsconfig.json",
"test": "mocha dist/test --opts test/mocha.opts",
"coverage": "istanbul cover -i dist/src/**/*.js --dir ./build/coverage node_modules/mocha/bin/_mocha -- dist/test --opts test/mocha.opts",
"remap": "remap-istanbul -i build/coverage/coverage.json -o coverage -t html",
@@ -33,6 +33,7 @@
],
"homepage": "https://github.com/css-blocks/css-blocks/tree/master/packages/webpack-plugin#readme",
"devDependencies": {
"@css-blocks/code-style": "^0.17.0",
"@types/async": "^2.0.40",
"@types/chai": "^3.5.2",
"@types/convert-source-map": "^1.3.33",
Oops, something went wrong.

0 comments on commit c361bc0

Please sign in to comment.