diff --git a/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl new file mode 100644 index 000000000..ae0af4562 --- /dev/null +++ b/src/main/resources/org/eolang/lints/names/invalid-name-notation.xsl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + warning + Object name + + does not follow kebab-case convention. Use lowercase letters and hyphens only. + + + + + diff --git a/src/main/resources/org/eolang/motives/names/invalid-name-notation.md b/src/main/resources/org/eolang/motives/names/invalid-name-notation.md new file mode 100644 index 000000000..44c876abd --- /dev/null +++ b/src/main/resources/org/eolang/motives/names/invalid-name-notation.md @@ -0,0 +1,26 @@ +# Invalid Name Notation + +**Lint ID:** `invalid-name-notation` + +**Rule:** All object names should follow kebab-case convention. + +## What + +Names like `my-object` are valid. Names like `MyObject`, `my_object`, or `123test` are not. + +## Why + +Consistent naming conventions reduce cognitive load when reading EO code. Kebab-case is the [official EO naming convention](https://www.eolang.org/convention.html). + +## Examples + +```eo +[] > my-object ✓ valid +[] > MyObject ✗ invalid (camelCase) +[] > my_object ✗ invalid (snake_case) +[] > 123test ✗ invalid (starts with digit) +``` + +## Fix + +Rename the object to follow kebab-case: use only lowercase letters, digits, and hyphens, starting with a letter. diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-valid-names.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-valid-names.yaml new file mode 100644 index 000000000..c69756403 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/allows-valid-names.yaml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/names/invalid-name-notation.xsl +asserts: + - /defects[count(defect[@severity='warning'])=0] +document: | + + + + + + \ No newline at end of file diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-camelcase.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-camelcase.yaml new file mode 100644 index 000000000..a9d9ce8d7 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-camelcase.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/names/invalid-name-notation.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='1'] +document: | + + + + \ No newline at end of file diff --git a/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-snake-case.yaml b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-snake-case.yaml new file mode 100644 index 000000000..09ad92014 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/invalid-name-notation/catches-snake-case.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/names/invalid-name-notation.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[@line='1'] +document: | + + + + \ No newline at end of file