Skip to content
Open
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
15 changes: 11 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"presets": [
"es2015",
"stage-1"
[
"@babel/preset-env",
{
"targets": {
"node": "16"
}
}
]
],
"plugins": [
"syntax-flow",
"transform-flow-strip-types"
"@babel/plugin-syntax-flow",
"@babel/transform-flow-strip-types",
"@babel/plugin-proposal-export-default-from"
],
"sourceMaps": "inline"
}
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib/packages/gonzales-primitives.js
build/
packages/gonzales-primitives.js
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"extends": [
"standard",
"plugin:import/errors",
Expand Down
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ build/
lib/

[version]
^0.36.0
^0.192.0
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: yarn-build
on: [push, pull_request]
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: borales/actions-yarn@v3.0.0
with:
cmd: install
- uses: borales/actions-yarn@v3.0.0
with:
cmd: lint
- uses: borales/actions-yarn@v3.0.0
with:
cmd: test
- uses: borales/actions-yarn@v3.0.0
with:
cmd: build
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
.DS_Store

build
node_modules/
.yarn/
build/
npm-debug.log

3 changes: 3 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"require": "@babel/register"
}
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules

21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# **status: NOT MAINTAINED**
# Updates
I fixed an issue with the resolver to be able to use features from [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import).

# original status: NOT MAINTAINED
I have moved on to using css-in-js libraries like styled-components and emotion.
So, not working on this project.

# eslint-plugin-css-modules

[![Build Status](https://travis-ci.org/atfzl/eslint-plugin-css-modules.svg?branch=master)](https://travis-ci.org/atfzl/eslint-plugin-css-modules)
[![yarn-build](https://github.com/GerroDen/eslint-plugin-css-modules/actions/workflows/main.yml/badge.svg)](https://github.com/GerroDen/eslint-plugin-css-modules/actions/workflows/main.yml)

This plugin intends to help you in tracking down problems when you are using css-modules. It tells if you are using a non-existent css/scss/less class in js or if you forgot to use some classes which you declared in css/scss/less.

Expand Down Expand Up @@ -73,20 +76,6 @@ The camelCase option has 4 possible values, see [css-loader#camelCase](https://g
true | "dashes" | "only" | "dashes-only"
```

## Specifying base path

You can specify path for the base directory via plugin settings in .eslintrc. This is used by the plugin to resolve absolute (S)CSS paths:

```json
{
"settings": {
"css-modules": {
"basePath": "app/scripts/..."
}
}
}
```

## Screen Shot

![ScreenShot](https://raw.githubusercontent.com/atfzl/eslint-plugin-css-modules/master/screenshots/screenshot3.png)
Expand Down
16 changes: 5 additions & 11 deletions lib/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path';
import fp from 'lodash/fp';
import _ from 'lodash';
import gonzales from './gonzales';
import resolve from 'eslint-module-utils/resolve';

import type { JsNode, gASTNode } from '../types';

Expand All @@ -26,14 +27,7 @@ function dashesCamelCase (str: string) {
}

export const getFilePath = (context, styleFilePath) => {
const settings = context.settings['css-modules'];

const dirName = path.dirname(context.getFilename());
const basePath = (settings && settings.basePath) ? settings.basePath : '';

return styleFilePath.startsWith('.')
? path.resolve(dirName, styleFilePath)
: path.resolve(basePath, styleFilePath);
return resolve(styleFilePath, context);
};

export const getPropertyName = (node: JsNode): ?string => {
Expand All @@ -43,9 +37,9 @@ export const getPropertyName = (node: JsNode): ?string => {
we won't use node.property.name because it is for cases like
s[abc] where abc is a variable
*/
? node.property.value
/* dot notation, eg s.header */
: node.property.name;
? node.property.value
/* dot notation, eg s.header */
: node.property.name;

/*
skip property names starting with _
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const configs = {
recommended: {
rules: {
'css-modules/no-unused-class': 2, // error
'css-modules/no-undef-class': 2, // error
'css-modules/no-undef-class': 2, // error
}
}
};
53 changes: 29 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"my-publish": "npm run my-pre-publish && yarn publish"
},
"engines": {
"node": ">=4.0.0"
"node": ">=16.0.0"
},
"packageManager": "yarn@3.2.1",
"keywords": [
"eslint",
"eslintplugin",
Expand All @@ -37,32 +38,36 @@
},
"license": "MIT",
"peerDependencies": {
"eslint": ">=2.0.0"
"eslint": ">=2.0.0",
"eslint-plugin-import": "*"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.0",
"babel-plugin-syntax-flow": "^6.18.0",
"babel-plugin-transform-flow-strip-types": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-1": "^6.16.0",
"babel-register": "^6.23.0",
"babel-watch": "^2.0.6",
"chai": "^3.5.0",
"concurrently": "^3.3.0",
"eslint": "^3.8.1",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-flowtype": "^2.25.0",
"eslint-plugin-import": "^2.0.1",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-standard": "^2.0.1",
"flow-bin": "^0.36.0",
"mocha": "^3.2.0",
"nodemon": "^1.11.0"
"@babel/cli": "^7.19.3",
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.20.2",
"@babel/plugin-proposal-export-default-from": "^7.18.10",
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"babel-watch": "^7.7.0",
"chai": "^4.3.6",
"concurrently": "^7.5.0",
"eslint": "^8.26.0",
"eslint-config-standard": "^17.0.0",
"eslint-module-utils": "^2.7.4",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.4.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"flow-bin": "^0.192.0",
"mocha": "^10.1.0",
"nodemon": "^2.0.20"
},
"dependencies": {
"gonzales-pe": "^4.0.3",
"lodash": "^4.17.2"
"gonzales-pe": "^4.3.0",
"lodash": "^4.17.21"
}
}
18 changes: 9 additions & 9 deletions test/lib/rules/no-undef-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ ruleTester.run('no-undef-class', rule, {
absolute import
eg: 'foo/bar.scss'
*/
test({
code: `
import s from 'test/files/noUndefClass1.scss';

export default Foo = () => (
<div className={s.container}></div>
);
`,
}),
// test({
// code: `
// import s from 'test/files/noUndefClass1.scss';
//
// export default Foo = () => (
// <div className={s.container}></div>
// );
// `,
// }),
/*
dot notation
eg: s.container
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

Loading