Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require meta.docs.url in every rule #47

Merged
merged 2 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .neutrinorc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ module.exports = {
plugins: ['self'],
rules: {
'self/latin-var-name-only': 'warn',
'self/no-rerely-used-words': 'warn'
'self/no-rerely-used-words': 'warn',
// 'self/no-special-in-object-members': 'warn',
'eslint-plugin/require-meta-docs-url': ['warn', {
'pattern': 'https://github.com/atomspace/eslint-plugin-naming-convention/blob/master/docs/rules/{{name}}.md'
}]
}
}
}],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/atomspace/eslint-plugin-naming-convention#readme",
"devDependencies": {
"@atomspace/eslint": "3.1.0",
"@atomspace/eslint": "3.3.0",
"@neutrinojs/jest": "8.3.0",
"@neutrinojs/node": "8.3.0",
"neutrino": "8.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/rules/latin-var-name-only/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./latin-var-name-only');
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ let findClosestLatinToCyrrilicCharSimilarity = require('./closest-latin-to-cyrri
module.exports = {
meta: {
type: 'problem',
docs: {
url: 'https://github.com/atomspace/eslint-plugin-naming-convention/blob/master/docs/rules/latin-var-name-only.md'
},
fixable: 'code'
},
create(context) {
create (context) {
return {
Identifier(node) {
Identifier (node) {
let varNameHasNonLatinSymbol = NOT_LATIN_SYMBOL_REGEXP.test(node.name);

if (varNameHasNonLatinSymbol) {
context.report({
node,
message: 'Variable name contains non-latin character',
message: 'Variable name contains non-latin character.',
fix: fixer => {
let member = node.name;

Expand Down
27 changes: 1 addition & 26 deletions src/rules/no-rerely-used-words/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
let checkRerelyUsedWords = require('./check-rerely-used-words');

module.exports = {
meta: {
messages: {
noRerelyUsedWords: 'Avoid using rerely used words in identifiers'
}
},
create (context) {
return {
Identifier (node) {
let isRerelyUsedWord = checkRerelyUsedWords(node.name);

if (isRerelyUsedWord) {
context.report({
node,
messageId: 'noRerelyUsedWords',
data: {
name: node.name
}
});
}
}
};
}
};
module.exports = require('./no-rerely-used-words');
29 changes: 29 additions & 0 deletions src/rules/no-rerely-used-words/no-rerely-used-words.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
let checkRerelyUsedWords = require('./check-rerely-used-words');

module.exports = {
meta: {
docs: {
url: 'https://github.com/atomspace/eslint-plugin-naming-convention/blob/master/docs/rules/no-rerely-used-words.md'
},
messages: {
noRerelyUsedWords: 'Avoid using rerely used words in identifiers.'
}
},
create (context) {
return {
Identifier (node) {
let isRerelyUsedWord = checkRerelyUsedWords(node.name);

if (isRerelyUsedWord) {
context.report({
node,
messageId: 'noRerelyUsedWords',
data: {
name: node.name
}
});
}
}
};
}
};
15 changes: 9 additions & 6 deletions src/rules/no-special-in-object-members.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@ const SPECIAL_SYMBOLS_REGEXP = /[!#%&()*+/=@^_]/;
module.exports = {
meta: {
type: 'problem',
docs: {
url: 'https://github.com/atomspace/eslint-plugin-naming-convention/blob/master/docs/rules/no-special-in-object-members.md'
},
messages: {
errorMessage: `The object member has special symbols: {{ listOfSpecialSymbolsInObjectMember }}`
errorMessage: `The object member has special symbols: {{ listOfSpecialSymbolsInObjectMember }}.`
}
},
create(context) {
create (context) {
return {
VariableDeclaration(node) {
VariableDeclaration (node) {
let objectProperties = node.declarations[0].init.properties;

objectProperties.forEach(property => {

let objectMemeber = property.key.value;
let specialSymbolInObjectMember = objectMemeber.match(SPECIAL_SYMBOLS_REGEXP);


if (specialSymbolInObjectMember) {
let listOfSpecialSymbolsInObjectMember = specialSymbolInObjectMember.join('');

context.report({
node: node,
node,
messageId: 'errorMessage',
data: {
listOfSpecialSymbolsInObjectMember: listOfSpecialSymbolsInObjectMember
listOfSpecialSymbolsInObjectMember
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/latin-var-name-only.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const latinVarNameOnly = require('../src/rules/latin-var-name-only-rule');
const latinVarNameOnly = require('../src/rules/latin-var-name-only');

let RuleTester = require('eslint').RuleTester;

Expand Down