options: [{ ignoreImports: true }],
parserOptions: { ecmaVersion: 6, sourceType: "module" }
},
+ {
+ code: "import { snake_cased as snake_cased } from 'mod'",
+ options: [{ ignoreImports: true }],
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" }
+ },
+ {
+ code: "import { 'snake_cased' as snake_cased } from 'mod'",
+ options: [{ ignoreImports: true }],
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" }
+ },
{
code: "import { camelCased } from 'mod'",
options: [{ ignoreImports: false }],
parserOptions: { ecmaVersion: 6, sourceType: "module" }
},
+
+ // this rule doesn't apply to quoted module export names, as it doesn't apply to quoted property names.
+ {
+ code: "export { a as 'snake_cased' } from 'mod'",
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" }
+ },
+ {
+ code: "export * as 'snake_cased' from 'mod'",
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" }
+ },
+
{
code: "var _camelCased = aGlobalVariable",
options: [{ ignoreGlobals: false }],
code: "class C { snake_case; #snake_case; #snake_case2() {} }",
options: [{ properties: "never" }],
parserOptions: { ecmaVersion: 2022 }
+ },
+
+ // Combinations of `properties` and `ignoreDestructuring`
+ {
+ code: `
+ const { some_property } = obj;
+
+ const bar = { some_property };
+
+ obj.some_property = 10;
+
+ const xyz = { some_property: obj.some_property };
+
+ const foo = ({ some_property }) => {
+ console.log(some_property)
+ };
+ `,
+ options: [{ properties: "never", ignoreDestructuring: true }],
+ parserOptions: { ecmaVersion: 2022 }
+ },
+
+ // https://github.com/eslint/eslint/issues/15572
+ {
+ code: `
+ const { some_property } = obj;
+ doSomething({ some_property });
+ `,
+ options: [{ properties: "never", ignoreDestructuring: true }],
+ parserOptions: { ecmaVersion: 2022 }
}
],
invalid: [
}
]
},
+ {
+ code: "import { 'snake_cased' as snake_cased } from 'mod'",
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" },
+ errors: [
+ {
+ messageId: "notCamelCase",
+ data: { name: "snake_cased" },
+ type: "Identifier"
+ }
+ ]
+ },
+ {
+ code: "import { 'snake_cased' as another_snake_cased } from 'mod'",
+ options: [{ ignoreImports: true }],
+ parserOptions: { ecmaVersion: 2022, sourceType: "module" },
+ errors: [
+ {
+ messageId: "notCamelCase",
+ data: { name: "another_snake_cased" },
+ type: "Identifier"
+ }
+ ]
+ },
{
code: "import { camelCased, no_camelcased } from \"external-module\";",
parserOptions: { ecmaVersion: 6, sourceType: "module" },
options: [{ properties: "always" }],
parserOptions: { ecmaVersion: 2022 },
errors: [{ messageId: "notCamelCasePrivate", data: { name: "snake_case" } }]
+ },
+
+ // Combinations of `properties` and `ignoreDestructuring`
+ {
+ code: `
+ const { some_property } = obj;
+ doSomething({ some_property });
+ `,
+ options: [{ properties: "always", ignoreDestructuring: true }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ messageId: "notCamelCase",
+ data: { name: "some_property" },
+ line: 3,
+ column: 27
+ }
+ ]
+ },
+ {
+ code: `
+ const { some_property } = obj;
+ doSomething({ some_property });
+ doSomething({ [some_property]: "bar" });
+ `,
+ options: [{ properties: "never", ignoreDestructuring: true }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ messageId: "notCamelCase",
+ data: { name: "some_property" },
+ line: 4,
+ column: 28
+ }
+ ]
+ },
+ {
+ code: `
+ const { some_property } = obj;
+
+ const bar = { some_property };
+
+ obj.some_property = 10;
+
+ const xyz = { some_property: obj.some_property };
+
+ const foo = ({ some_property }) => {
+ console.log(some_property)
+ };
+ `,
+ options: [{ properties: "always", ignoreDestructuring: true }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ {
+ messageId: "notCamelCase",
+ data: { name: "some_property" },
+ line: 4,
+ column: 27
+ },
+ {
+ messageId: "notCamelCase",
+ data: { name: "some_property" },
+ line: 6,
+ column: 17
+ },
+ {
+ messageId: "notCamelCase",
+ data: { name: "some_property" },
+ line: 8,
+ column: 27
+ }
+ ]
}
]
});