Skip to content

Commit

Permalink
JS-469 Remove unused scripts (#4970)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez authored Dec 2, 2024
1 parent b610d33 commit 101d75f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 46 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"bf": "npm run build:fast",
"new-rule": "tsx tools/new-rule.mts",
"generate-meta": "tsx tools/generate-meta.ts npm run eslint-docs",
"generate-rules-list": "node tools/generate-rules-list.js",
"ruling": "node tools/prepare-ruling.js && tsx --tsconfig packages/tsconfig.test.json --test packages/ruling/tests/projects/*.ruling.test.ts",
"ruling-parametrized": "node tools/prepare-ruling.js && SONAR_RULING_SETTINGS=../settings.js tsx --tsconfig packages/tsconfig.test.json --test packages/ruling/tests/projects/*.ruling.test.ts",
"ruling-sync": "rsync -avh packages/ruling/tests/actual/jsts/ its/ruling/src/test/expected/jsts/ --delete",
Expand All @@ -34,7 +33,7 @@
"count-rules": "node tools/count-rules.js",
"_:bridge:copy-protofiles": "cpy --flat packages/jsts/src/parsers/estree.proto sonar-plugin/bridge/src/main/protobuf && cpy --flat packages/jsts/src/parsers/estree.proto lib/jsts/src/parsers",
"_:bridge:clear": "rimraf --glob lib/*",
"_:plugin:prepare-bridge": "npm pack && npm run _:plugin:copy-bridge && npm run generate-rules-list",
"_:plugin:prepare-bridge": "npm pack && npm run _:plugin:copy-bridge",
"_:plugin-fetch-node": "node tools/fetch-node/scripts/wrapper.mjs",
"_:plugin:pre-build": "npm run _:plugin:prepare-bridge && npm run _:plugin-fetch-node",
"_:plugin:copy-bridge": "cpy sonarjs-1.0.0.tgz sonar-plugin/sonar-javascript-plugin/target/classes && cpy sonarjs-1.0.0.tgz sonar-plugin/standalone/target/classes",
Expand Down
32 changes: 0 additions & 32 deletions tools/generate-rules-list.js

This file was deleted.

8 changes: 2 additions & 6 deletions tools/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,14 @@ export function verifyRspecId(sonarKey: string) {
}
}

export function escapeRegExp(str: string) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
}

/**
* Inflate string template with given dictionary
* @param text template string
* @param dictionary object with the keys to replace
*/
export function inflateTemplate(text: string, dictionary: { [x: string]: string }): string {
for (const tok in dictionary) {
text = text.replace(new RegExp(escapeRegExp(tok), 'g'), dictionary[tok]);
for (const key in dictionary) {
text = text.replaceAll(key, dictionary[key]);
}
return text;
}
Expand Down
3 changes: 1 addition & 2 deletions tools/new-rule.mts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ await inflateTemplateToFile(
join(JAVA_TEMPLATES_FOLDER, ruleTarget === 'MAIN' ? 'rule.main.template' : 'rule.test.template'),
join(javaChecksPath('main'), `${sonarKey}.java`),
{
___JAVA_RULE_CLASS_NAME___: sonarKey,
___RULE_KEY___: sonarKey,
___PROPERTIES___: await readFile(join(JAVA_TEMPLATES_FOLDER, 'properties'), 'utf8'),
___HEADER___: header,
Expand All @@ -144,7 +143,7 @@ await inflateTemplateToFile(
join(JAVA_TEMPLATES_FOLDER, 'ruletest.template'),
join(javaChecksPath('test'), `${sonarKey}Test.java`),
{
___JAVA_RULE_CLASS_NAME___: sonarKey,
___RULE_KEY___: sonarKey,
___HEADER___: header,
},
);
Expand Down
2 changes: 1 addition & 1 deletion tools/templates/java/rule.main.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import org.sonar.plugins.javascript.api.TypeScriptRule;
@TypeScriptRule
@JavaScriptRule
@Rule(key = "___RULE_KEY___")
public class ___JAVA_RULE_CLASS_NAME___ extends Check {
public class ___RULE_KEY___ extends Check {
___PROPERTIES___
}
2 changes: 1 addition & 1 deletion tools/templates/java/rule.test.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import org.sonar.plugins.javascript.api.TypeScriptRule;
@JavaScriptRule
@TypeScriptRule
@Rule(key = "___RULE_KEY___")
public class ___JAVA_RULE_CLASS_NAME___ extends TestFileCheck {
public class ___RULE_KEY___ extends TestFileCheck {
___PROPERTIES___
}
4 changes: 2 additions & 2 deletions tools/templates/java/ruletest.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import com.google.gson.Gson;
import org.junit.jupiter.api.Test;

// TODO: delete this file if the rule is not configurable
class ___JAVA_RULE_CLASS_NAME___Test {
class ___RULE_KEY___Test {
@Test
void configurations() {
___JAVA_RULE_CLASS_NAME___ check = new ___JAVA_RULE_CLASS_NAME___();
___RULE_KEY___ check = new ___RULE_KEY___();
// default configuration
String defaultConfigAsString = new Gson().toJson(check.configurations());
assertThat(defaultConfigAsString).isEqualTo("[{\"property\":\"\"}]");
Expand Down

0 comments on commit 101d75f

Please sign in to comment.