Skip to content

Commit

Permalink
feat: install linter (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent authored Jan 12, 2024
1 parent 45c89f1 commit 3a5bb4f
Show file tree
Hide file tree
Showing 28 changed files with 2,018 additions and 796 deletions.
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 🤖 Linear

Closes BES-XXX
6 changes: 3 additions & 3 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
- name: Install Node
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Install Dependencies
run: yarn --frozen-lockfile
Expand All @@ -29,4 +29,4 @@ jobs:
- name: Publish
run: npm publish --access public --tag canary
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint

on: [push]

jobs:
files:
runs-on: ubuntu-latest

steps:
- name: Check out github repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"

- name: Install dependencies
run: yarn --frozen-lockfile

- name: Run linter
run: yarn run lint:check
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: Install Node
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Install Dependencies
run: yarn --frozen-lockfile
Expand All @@ -28,4 +28,4 @@ jobs:
- name: Publish
run: yarn publish --access public --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32 changes: 16 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ jobs:
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install Solc AST binary
run: yarn global add solc-typed-ast
- name: Install Solc AST binary
run: yarn global add solc-typed-ast

- name: Install dependencies
run: yarn install
- name: Install dependencies
run: yarn install

- name: Pre-download compilers from historical builds archive
run: |
sol-ast-compile --download-compilers native wasm
find $SOL_AST_COMPILER_CACHE -name 'list.json' -delete
find $SOL_AST_COMPILER_CACHE -name '*v0.5.17*' -delete
- name: Pre-download compilers from historical builds archive
run: |
sol-ast-compile --download-compilers native wasm
find $SOL_AST_COMPILER_CACHE -name 'list.json' -delete
find $SOL_AST_COMPILER_CACHE -name '*v0.5.17*' -delete
- name: Run tests
run: yarn test
- name: Run tests
run: yarn test
25 changes: 25 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Dependency directories
actions/node_modules/
node_modules/
actions/package-lock.json

# Ignore tsc output
lib

# Config files
.env
.vscode

# yarn
yarn-error.log

# Other
.DS_STORE
.env.example
.env
.prettierignore
.gitignore
.github/CODEOWNERS
.husky/_/husky.sh
yarn.lock
LICENSE
22 changes: 22 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"overrides": [
{
"files": ["**.ts", "**.js"],
"options": {
"printWidth": 145,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"useTabs": false,
"endOfLine": "auto"
}
},
{
"files": "**.json",
"options": {
"tabWidth": 2,
"printWidth": 200
}
}
]
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,37 @@ Some description will be written here.
## Usage

As simple as it gets, run:

```bash
npx @defi-wonderland/natspec-smells --contracts ./solidity
```

## Options

### `--contracts` (Required)

Relative path to your solidity files.

### `--root`

Root directory to be used.

Default: `./`

### `--enforceInheritdoc`

Whether `@inheritdoc` is used or not.

Default: `true`

### `--constructorNatspec`

Whether to enforce natspec for constructors.

Default: `false`

### `--ignore`

Glob pattern of files and directories to exclude from processing.

Default: `[]`
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
};
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@
"types": "lib/main.d.ts",
"bin": "./lib/main.js",
"scripts": {
"start": "ts-node ./src/main.ts",
"build": "tsc",
"lint:check": "prettier --check .",
"lint:fix": "sort-package-json && prettier --write .",
"start": "ts-node ./src/main.ts",
"test": "jest ./test"
},
"lint-staged": {
"package.json": "sort-package-json",
"**/*": "prettier --write --ignore-unknown"
},
"dependencies": {
"fast-glob": "3.3.2",
"solc-typed-ast": "17.0.3",
"yargs": "17.7.2"
},
"devDependencies": {
"@commitlint/cli": "17.6.5",
"@commitlint/config-conventional": "17.6.5",
"@types/jest": "29.5.11",
"@types/node": "20.10.7",
"jest": "29.7.0",
"lint-staged": "13.2.2",
"prettier": "2.8.8",
"sort-package-json": "2.4.1",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"typescript": "5.3.3"
Expand Down
130 changes: 67 additions & 63 deletions sample-data/BasicSample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,80 @@
pragma solidity =0.8.19;

contract BasicSample {
/**
* @notice Some notice of the struct
*/
struct TestStruct {
address someAddress;
uint256 someNumber;
}
/**
* @notice Some notice of the struct
*/
struct TestStruct {
address someAddress;
uint256 someNumber;
}

/**
* @notice Some error missing parameter natspec
*/
error BasicSample_SomeError(uint256 _param1);
/**
* @notice Some error missing parameter natspec
*/
error BasicSample_SomeError(uint256 _param1);

/**
* @notice An event missing parameter natspec
*/
event BasicSample_BasicEvent(uint256 _param1);
/**
* @notice An event missing parameter natspec
*/
event BasicSample_BasicEvent(uint256 _param1);

/**
* @notice Empty string for revert checks
* @dev result of doing keccak256(bytes(''))
*/
bytes32 internal constant _EMPTY_STRING = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
/**
* @notice Empty string for revert checks
* @dev result of doing keccak256(bytes(''))
*/
bytes32 internal constant _EMPTY_STRING = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

/**
* @notice External function that returns a bool
* @dev A dev comment
* @param _magicNumber A parameter description
* @param _name Another parameter description
* @return _isMagic Some return data
*/
function externalSimple(uint256 _magicNumber, string memory _name) external pure returns(bool _isMagic) {
return true;
}
/**
* @notice External function that returns a bool
* @dev A dev comment
* @param _magicNumber A parameter description
* @param _name Another parameter description
* @return _isMagic Some return data
*/
function externalSimple(uint256 _magicNumber, string memory _name) external pure returns (bool _isMagic) {
return true;
}

/**
* @notice Private test function
* @param _magicNumber A parameter description
*/
function privateSimple(uint256 _magicNumber) private pure {}
/**
* @notice Private test function
* @param _magicNumber A parameter description
*/
function privateSimple(uint256 _magicNumber) private pure {}

/**
* @notice Private test function
* with multiple
* lines
*/
function multiline() external pure {}
/**
* @notice Private test function
* with multiple
* lines
*/
function multiline() external pure {}

/**
* @notice Private test function
* @notice Another notice
*/
function multitag() external pure {}
/**
* @notice Private test function
* @notice Another notice
*/
function multitag() external pure {}

/**
* @notice External function that returns a bool
* @dev A dev comment
* @param _magicNumber A parameter description
* @param _name Another parameter description
* @return _isMagic Some return data
* @return Test test
*/
function externalSimpleMultipleReturn(uint256 _magicNumber, string memory _name) external pure returns(bool _isMagic, uint256) {
return (true, 111);
}
/**
* @notice External function that returns a bool
* @dev A dev comment
* @param _magicNumber A parameter description
* @param _name Another parameter description
* @return _isMagic Some return data
* @return Test test
*/
function externalSimpleMultipleReturn(uint256 _magicNumber, string memory _name)
external
pure
returns (bool _isMagic, uint256)
{
return (true, 111);
}

/**
* @notice Modifier notice
*/
modifier transferFee(uint256 _receiver) {
_;
}
/**
* @notice Modifier notice
*/
modifier transferFee(uint256 _receiver) {
_;
}
}
Loading

0 comments on commit 3a5bb4f

Please sign in to comment.