Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(lint): Introduce shared lint configuration and initial code sty…
…le documentation.
- Loading branch information
1 parent
5b28b71
commit c361bc0
Showing
20 changed files
with
430 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'subject-full-stop': [2, 'always', '.'], | ||
'subject-case': [ | ||
2, 'always', | ||
['sentence-case'] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"transpiled" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 — 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.