-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Procházka Václav
committed
Jan 12, 2024
1 parent
d96b0dc
commit 709acc7
Showing
8 changed files
with
8,842 additions
and
1 deletion.
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,21 @@ | ||
name: Publish to NPM | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '14.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install dependencies and build 🔧 | ||
run: npm ci && npm run build | ||
- name: Publish package on NPM 📦 | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,22 @@ | ||
.DS_Store | ||
node_modules | ||
dist | ||
|
||
# local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,2 +1,28 @@ | ||
# eslint-plugin-sentences | ||
eslint plugin to warn prohibit sentences in code | ||
|
||
Prohibit words, sentences in code & comments. | ||
|
||
## Installation | ||
|
||
Install [ESLint](https://github.com/eslint/eslint) either locally or globally. | ||
|
||
```bash | ||
npm install --save-dev eslint | ||
``` | ||
|
||
```bash | ||
npm install --save-dev eslint-plugin-sentences | ||
``` | ||
|
||
## Configuration via .eslintrc | ||
|
||
```js | ||
{ | ||
"plugins": [ | ||
"sentences" | ||
], | ||
"rules": { | ||
"sentences/no-sentences": [`error`, ['prohibit sentence']] | ||
} | ||
} | ||
``` |
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,46 @@ | ||
const rule = require("../rules/no-sentences"); | ||
RuleTester = require("eslint").RuleTester; | ||
|
||
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2015, sourceType: "module", } }); | ||
|
||
ruleTester.run("no-sentences", rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
// code | ||
var x = 5; | ||
`, | ||
options: ['forbidden code'], | ||
}, | ||
{ | ||
code: ` | ||
// code | ||
var x = 5; | ||
`, | ||
options: ['xz', 'xx'], | ||
} | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: ` | ||
// forbidden code | ||
var forbiddenCode = 34 | ||
`, | ||
errors: [{ | ||
message: 'Avoid using the specified sentence in the code', | ||
}], | ||
options: ['forbidden code'], | ||
}, | ||
{ | ||
code: ` | ||
// code | ||
var forbiddenCode = 34 | ||
`, | ||
errors: [{ | ||
message: 'Avoid using the specified sentence in the code', | ||
}], | ||
options: ['forbidden code' ,'forbiddenCode'], | ||
}, | ||
] | ||
}) |
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,3 @@ | ||
const noSentencesRule = require("./rules/no-sentences"); | ||
const plugin = { rules: { "no-sentences": noSentencesRule } }; | ||
module.exports = plugin; |
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,31 @@ | ||
module.exports = { | ||
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
description: 'Disallow the specified sentence', | ||
}, | ||
schema: { | ||
type: "array", | ||
items: { | ||
string: ["always", "never"] | ||
}, | ||
} | ||
}, | ||
create: function (context) { | ||
return { | ||
Program: function (node) { | ||
const code = context.sourceCode.getText(); | ||
const comments = context.sourceCode.getAllComments(); | ||
|
||
context.options.forEach((option) => { | ||
if (code.includes(option) || comments.includes(option)) { | ||
context.report({ | ||
node, | ||
message: 'Avoid using the specified sentence in the code', | ||
}); | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.